X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/34326da778583ca8eab95f2e41738da2852a5a16..e7aa9bb7c0381c735cecba13abc7cb2b3c077c66:/src/gtk/webview_webkit.cpp diff --git a/src/gtk/webview_webkit.cpp b/src/gtk/webview_webkit.cpp index 52f755b0f3..ea5abe7c0a 100644 --- a/src/gtk/webview_webkit.cpp +++ b/src/gtk/webview_webkit.cpp @@ -32,6 +32,11 @@ wxgtk_webview_webkit_load_status(GtkWidget* widget, GParamSpec*, wxWebViewWebKit *webKitCtrl) { + // We can be called from webkit_web_view_dispose() during the window + // destruction, don't use half-destroyed object in this case. + if ( webKitCtrl->IsBeingDeleted() ) + return; + wxString url = webKitCtrl->GetCurrentURL(); WebKitLoadStatus status; @@ -396,6 +401,10 @@ bool wxWebViewWebKit::Create(wxWindow *parent, m_busy = false; m_guard = false; + // We currently unconditionally impose scrolling in both directions as it's + // necessary to show arbitrary pages. + style |= wxHSCROLL | wxVSCROLL; + if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { @@ -403,13 +412,9 @@ bool wxWebViewWebKit::Create(wxWindow *parent, return false; } - m_widget = gtk_scrolled_window_new(NULL, NULL); - g_object_ref(m_widget); m_web_view = WEBKIT_WEB_VIEW(webkit_web_view_new()); - - /* Place the WebKitWebView in the GtkScrolledWindow */ - gtk_container_add(GTK_CONTAINER(m_widget), GTK_WIDGET(m_web_view)); - gtk_widget_show(GTK_WIDGET(m_web_view)); + GTKCreateScrolledWindowWith(GTK_WIDGET(m_web_view)); + g_object_ref(m_widget); g_signal_connect_after(m_web_view, "navigation-policy-decision-requested", G_CALLBACK(wxgtk_webview_webkit_navigation), @@ -447,12 +452,21 @@ bool wxWebViewWebKit::Create(wxWindow *parent, return true; } +wxWebViewWebKit::~wxWebViewWebKit() +{ + // The main goal here is to set m_isBeingDeleted to true to avoid the use + // of this -- already half-destroyed -- object from WebKit callbacks, but + // just setting it would prevent wxWindowDestroyEvent from being sent, so + // send it now instead. + SendDestroyEvent(); +} + bool wxWebViewWebKit::Enable( bool enable ) { if (!wxControl::Enable(enable)) return false; - gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable); + gtk_widget_set_sensitive(gtk_bin_get_child(GTK_BIN(m_widget)), enable); //if (enable) // GTKFixSensitivity(); @@ -763,7 +777,7 @@ bool wxWebViewWebKit::CanSetZoomType(wxWebViewZoomType) const return true; } -void wxWebViewWebKit::SetPage(const wxString& html, const wxString& baseUri) +void wxWebViewWebKit::DoSetPage(const wxString& html, const wxString& baseUri) { webkit_web_view_load_string (m_web_view, html.mb_str(wxConvUTF8),