Merge branch 'WebKitFileMemory' of github.com:Blake-Madden/wxWidgets

Fix leaking wxFSFile in WebKit-based wxWebView in wxGTK.

See #26802.
This commit is contained in:
Vadim Zeitlin
2026-08-09 18:38:21 +02:00
3 changed files with 8 additions and 4 deletions
+3 -1
View File
@@ -731,7 +731,9 @@ public:
wxWebViewHandler(const wxString& scheme);
/**
@return A pointer to the file represented by @c uri.
@return A pointer to the file represented by @c uri, or @NULL. The
caller takes ownership of the returned pointer and is responsible for
deleting it.
*/
virtual wxFSFile* GetFile(const wxString &uri);
+3 -2
View File
@@ -20,6 +20,7 @@
#include "wx/log.h"
#include "wx/private/webview.h"
#include "wx/scopedptr.h"
#include <webkit/webkit.h>
@@ -158,7 +159,7 @@ wxgtk_webview_webkit_navigation(WebKitWebView *,
if(handler)
{
webKitCtrl->m_guard = true;
wxFSFile* file = handler->GetFile(wxuri);
wxScopedPtr<wxFSFile> file(handler->GetFile(wxuri));
if(file)
{
webKitCtrl->SetPage(*file->GetStream(), wxuri);
@@ -385,7 +386,7 @@ wxgtk_webview_webkit_resource_req(WebKitWebView *,
if(webKitCtrl->m_vfsurl == uri)
return;
wxFSFile* file = handler->GetFile(uri);
wxScopedPtr<wxFSFile> file(handler->GetFile(uri));
if(file)
{
//We load the data into a data url to save it being written out again
+2 -1
View File
@@ -38,6 +38,7 @@
#include "wx/gtk/private/object.h"
#include "wx/gtk/private/variant.h"
#include "wx/private/jsscriptwrapper.h"
#include "wx/scopedptr.h"
#include <webkit2/webkit2.h>
#include <JavaScriptCore/JSValueRef.h>
#include <JavaScriptCore/JSStringRef.h>
@@ -500,7 +501,7 @@ wxgtk_webview_webkit_uri_scheme_request_cb(WebKitURISchemeRequest *request,
{
const wxString uri = wxString::FromUTF8(webkit_uri_scheme_request_get_uri(request));
wxFSFile* file = handler->GetFile(uri);
wxScopedPtr<wxFSFile> file(handler->GetFile(uri));
if(file)
{
gint64 length = file->GetStream()->GetLength();