]> git.saurik.com Git - wxWidgets.git/commitdiff
Disconnect all GTK signals referencing a wx object which is being destructed
authorPaul Cornett <paulcor@bullseye.com>
Wed, 17 Oct 2012 16:23:18 +0000 (16:23 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Wed, 17 Oct 2012 16:23:18 +0000 (16:23 +0000)
or which is destroying the associated GTK object

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72696 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

28 files changed:
include/wx/gtk/combobox.h
include/wx/gtk/filectrl.h
include/wx/gtk/minifram.h
include/wx/gtk/slider.h
include/wx/gtk/webview_webkit.h
include/wx/gtk/window.h
src/gtk/checkbox.cpp
src/gtk/choice.cpp
src/gtk/combobox.cpp
src/gtk/control.cpp
src/gtk/dataview.cpp
src/gtk/filectrl.cpp
src/gtk/glcanvas.cpp
src/gtk/listbox.cpp
src/gtk/menu.cpp
src/gtk/minifram.cpp
src/gtk/msgdlg.cpp
src/gtk/nativewin.cpp
src/gtk/radiobox.cpp
src/gtk/radiobut.cpp
src/gtk/slider.cpp
src/gtk/spinbutt.cpp
src/gtk/spinctrl.cpp
src/gtk/textctrl.cpp
src/gtk/tglbtn.cpp
src/gtk/toplevel.cpp
src/gtk/webview_webkit.cpp
src/gtk/window.cpp

index e31a347c8ec2bf3f053e110684a9512f615b3ec4..87aae8d9b9cad4e9b3219971e50945fd0c8c6b9a 100644 (file)
@@ -56,6 +56,7 @@ public:
         Init();
         Create(parent, id, value, pos, size, choices, style, validator, name);
     }
+    ~wxComboBox();
 
     bool Create(wxWindow *parent, wxWindowID id,
                 const wxString& value = wxEmptyString,
index 0af8939ee72d10af8fce8bcf25f1e3cac753704a..4d11d7f59ceb5e05e67b8a7ef3be88ff961063d9 100644 (file)
@@ -88,7 +88,7 @@ public:
         Create( parent, id, defaultDirectory, defaultFilename, wildCard, style, pos, size, name );
     }
 
-    virtual ~wxGtkFileCtrl() {}
+    virtual ~wxGtkFileCtrl();
 
     bool Create( wxWindow *parent,
                  wxWindowID id,
index de339f016a57a8b0bbbf01cf62e11bc1ffef6db9..119ff2602af627ccd515c723edb9a3cced5261a9 100644 (file)
@@ -33,6 +33,7 @@ public:
     {
         Create(parent, id, title, pos, size, style, name);
     }
+    ~wxMiniFrame();
 
     bool Create(wxWindow *parent,
             wxWindowID id,
index 50e9df086c04642bb6487fd3628bccccbc58d324..0476b55aaee1269d050f654b7f04e232550f0e85 100644 (file)
@@ -30,6 +30,7 @@ public:
         Create( parent, id, value, minValue, maxValue,
                 pos, size, style, validator, name );
     }
+    ~wxSlider();
 
     bool Create(wxWindow *parent,
                 wxWindowID id,
index 00ba41eb82bb68405ab790850ed77ec839f5f33b..2246303c509aa5fa25749067c5f0003587cbfeb5 100644 (file)
@@ -10,7 +10,7 @@
 #ifndef _WX_GTK_WEBKITCTRL_H_
 #define _WX_GTK_WEBKITCTRL_H_
 
-#include "wx/setup.h"
+#include "wx/defs.h"
 
 #if wxUSE_WEBVIEW && wxUSE_WEBVIEW_WEBKIT && defined(__WXGTK__)
 
@@ -26,7 +26,7 @@ typedef struct _WebKitWebView WebKitWebView;
 class WXDLLIMPEXP_WEBVIEW wxWebViewWebKit : public wxWebView
 {
 public:
-    wxWebViewWebKit() { }
+    wxWebViewWebKit();
 
     wxWebViewWebKit(wxWindow *parent,
            wxWindowID id = wxID_ANY,
index 9a1efc1cc81454ef393b81d59b173709d550cb6d..baeb7041fb465ffec5e2ecdc0b3bb1eaf15c8059 100644 (file)
@@ -59,8 +59,6 @@ public:
     // implement base class (pure) virtual methods
     // -------------------------------------------
 
-    virtual bool Destroy();
-
     virtual void Raise();
     virtual void Lower();
 
@@ -308,7 +306,6 @@ public:
     // extra (wxGTK-specific) flags
     bool                 m_noExpose:1;          // wxGLCanvas has its own redrawing
     bool                 m_nativeSizeEvent:1;   // wxGLCanvas sends wxSizeEvent upon "alloc_size"
-    bool                 m_hasVMT:1;            // set after PostCreation() is called
     bool                 m_isScrolling:1;       // dragging scrollbar thumb?
     bool                 m_clipPaintRegion:1;   // true after ScrollWindow()
     wxRegion             m_nativeUpdateRegion;  // not transformed for RTL
@@ -352,6 +349,7 @@ protected:
 
     void GTKFreezeWidget(GtkWidget *w);
     void GTKThawWidget(GtkWidget *w);
+    void GTKDisconnect(void* instance);
 
 #if wxUSE_TOOLTIPS
     virtual void DoSetToolTip( wxToolTip *tip );
index 3fb4de8aea8960d5f8212fd4b886ce99ca17a2f5..b19cacc6d3f8bdcd8fd2a3250f7fbc28cf341367 100644 (file)
@@ -30,8 +30,6 @@ extern bool           g_blockEventsOnDrag;
 extern "C" {
 static void gtk_checkbox_toggled_callback(GtkWidget *widget, wxCheckBox *cb)
 {
-    if (!cb->m_hasVMT) return;
-
     if (g_blockEventsOnDrag) return;
 
     // Transitions for 3state checkbox must be done manually, GTK's checkbox
index 32afd942461d089e71eeee72ea06d9b38609a428..dbc8579872dfd0ebc38d1ff42ca712d51f78f842 100644 (file)
@@ -103,9 +103,6 @@ wxChoice::~wxChoice()
 
 void wxChoice::SendSelectionChangedEvent(wxEventType evt_type)
 {
-    if (!m_hasVMT)
-        return;
-
     if (GetSelection() == -1)
         return;
 
index 35a5e0fec81560896a0fb2a21167b88f5a2f50d2..d29e2acb48d87f1bcb1f85e8d8f097ba1dc26ba6 100644 (file)
@@ -33,8 +33,6 @@ extern "C" {
 static void
 gtkcombobox_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
 {
-    if (!combo->m_hasVMT) return;
-
     wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
     event.SetString( combo->GetValue() );
     event.SetEventObject( combo );
@@ -87,6 +85,12 @@ BEGIN_EVENT_TABLE(wxComboBox, wxChoice)
     EVT_UPDATE_UI(wxID_SELECTALL, wxComboBox::OnUpdateSelectAll)
 END_EVENT_TABLE()
 
+wxComboBox::~wxComboBox()
+{
+    if (m_entry)
+        GTKDisconnect(m_entry);
+}
+
 void wxComboBox::Init()
 {
     m_entry = NULL;
index 40c21e9e15cd225caaed051db60b96fb080127d6..b03023f07e0578e252e516ab09b0d27cf0d4fa58 100644 (file)
@@ -139,9 +139,7 @@ void wxControl::GTKFixSensitivity(bool WXUNUSED_IN_GTK3(onlyIfUnderMouse))
 #endif
         )
     {
-        wxPoint pt = wxGetMousePosition();
-        wxRect rect(ClientToScreen(wxPoint(0, 0)), GetSize());
-        if (!onlyIfUnderMouse || rect.Contains(pt))
+        if (!onlyIfUnderMouse || GetScreenRect().Contains(wxGetMousePosition()))
         {
             Hide();
             Show();
index cf97ded4196ab144da10c7892b663bd08fbc389a..26bc7cc8a7e18810921f1a9b43fdbf5f71d8cbff 100644 (file)
@@ -4462,6 +4462,11 @@ wxDataViewCtrl::~wxDataViewCtrl()
             // This won't do anything if we're not editing it
             wxcol->GetRenderer()->CancelEditing();
         }
+
+        GTKDisconnect(m_treeview);
+        GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(m_treeview));
+        if (selection)
+            GTKDisconnect(selection);
     }
 
     m_cols.Clear();
@@ -4471,6 +4476,7 @@ wxDataViewCtrl::~wxDataViewCtrl()
 
 void wxDataViewCtrl::Init()
 {
+    m_treeview = NULL;
     m_internal = NULL;
 
     m_cols.DeleteContents( true );
index 70cd51acbd58329ac439cd9f292f3c1b21e55ff9..7eaf55511731393e938f559e86e81e9fee725acb 100644 (file)
@@ -285,6 +285,12 @@ extern "C"
 
 IMPLEMENT_DYNAMIC_CLASS( wxGtkFileCtrl, wxControl )
 
+wxGtkFileCtrl::~wxGtkFileCtrl()
+{
+    if (m_fcWidget)
+        GTKDisconnect(m_fcWidget);
+}
+
 void wxGtkFileCtrl::Init()
 {
     m_checkNextSelEvent = false;
index 7ab78cc4990c006ff5cef65e4e9a81d5163f144d..bdeb7d0cc6fc1ca3d3b7574847f4cea2db1e6a16 100644 (file)
@@ -99,9 +99,6 @@ gtk_glcanvas_size_callback(GtkWidget *WXUNUSED(widget),
                            GtkAllocation * WXUNUSED(alloc),
                            wxGLCanvas *win)
 {
-    if (!win->m_hasVMT)
-        return;
-
     wxSizeEvent event( wxSize(win->m_width,win->m_height), win->GetId() );
     event.SetEventObject( win );
     win->HandleWindowEvent( event );
index 788f1f4cb22cd9438f2ca39f1faf143799fe3105..b3fcefba4119d15b612e4a22a770e8d93e463ef5 100644 (file)
@@ -404,7 +404,13 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
 
 wxListBox::~wxListBox()
 {
-    m_hasVMT = false;
+    if (m_treeview)
+    {
+        GTKDisconnect(m_treeview);
+        GtkTreeSelection* selection = gtk_tree_view_get_selection(m_treeview);
+        if (selection)
+            GTKDisconnect(selection);
+    }
 
     Clear();
 }
index 8e2bc9647abf91ecc791cff1b27edf3ca60e22b4..54856e2c7d39bb846e3068efc6f90b74cc303801 100644 (file)
@@ -70,8 +70,7 @@ wxMenuBar::~wxMenuBar()
         GtkWidget* widget = m_widget;
         m_focusWidget =
         m_widget = NULL;
-        g_signal_handlers_disconnect_matched(widget,
-            GSignalMatchType(G_SIGNAL_MATCH_DATA), 0, 0, NULL, NULL, this);
+        GTKDisconnect(widget);
         g_object_unref(widget);
     }
 }
@@ -750,7 +749,8 @@ wxMenu::~wxMenu()
     // Destroying a menu generates a "hide" signal even if it's not shown
     // currently, so disconnect it to avoid dummy wxEVT_MENU_CLOSE events
     // generation.
-    g_signal_handlers_disconnect_by_func(m_menu, (gpointer)menu_hide, this);
+    g_signal_handlers_disconnect_matched(m_menu,
+        GSignalMatchType(G_SIGNAL_MATCH_DATA), 0, 0, NULL, NULL, this);
 
     // see wxMenu::Init
     g_object_unref(m_menu);
@@ -913,6 +913,10 @@ wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
         return NULL;
 
     GtkWidget * const mitem = item->GetMenuItem();
+
+    g_signal_handlers_disconnect_matched(mitem,
+        GSignalMatchType(G_SIGNAL_MATCH_DATA), 0, 0, NULL, NULL, item);
+
 #ifdef __WXGTK3__
     gtk_menu_item_set_submenu(GTK_MENU_ITEM(mitem), NULL);
 #else
index bd3261e2b13dfb14a4d2ca957abe8128c27a030a..0cf5dd8d24b2bcc0b7439667f00cd1e38592fca7 100644 (file)
@@ -81,7 +81,7 @@ static gboolean expose_event(GtkWidget* widget, GdkEventExpose* gdk_event, wxMin
 
     wxGTKCairoDC dc(cr);
 #else
-    if (!win->m_hasVMT || gdk_event->count > 0 ||
+    if (gdk_event->count > 0 ||
         gdk_event->window != gtk_widget_get_window(widget))
     {
         return false;
@@ -144,7 +144,7 @@ extern "C" {
 static gboolean
 gtk_window_button_press_callback(GtkWidget* widget, GdkEventButton* gdk_event, wxMiniFrame* win)
 {
-    if (!win->m_hasVMT || gdk_event->window != gtk_widget_get_window(widget))
+    if (gdk_event->window != gtk_widget_get_window(widget))
         return false;
     if (g_blockEventsOnDrag) return TRUE;
     if (g_blockEventsOnScroll) return TRUE;
@@ -224,7 +224,7 @@ extern "C" {
 static gboolean
 gtk_window_button_release_callback(GtkWidget* widget, GdkEventButton* gdk_event, wxMiniFrame* win)
 {
-    if (!win->m_hasVMT || gdk_event->window != gtk_widget_get_window(widget))
+    if (gdk_event->window != gtk_widget_get_window(widget))
         return false;
     if (g_blockEventsOnDrag) return TRUE;
     if (g_blockEventsOnScroll) return TRUE;
@@ -257,9 +257,8 @@ extern "C" {
 static gboolean
 gtk_window_leave_callback(GtkWidget *widget,
                           GdkEventCrossing* gdk_event,
-                          wxMiniFrame *win)
+                          wxMiniFrame*)
 {
-    if (!win->m_hasVMT) return FALSE;
     if (g_blockEventsOnDrag) return FALSE;
     if (gdk_event->window != gtk_widget_get_window(widget))
         return false;
@@ -278,7 +277,7 @@ extern "C" {
 static gboolean
 gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxMiniFrame *win )
 {
-    if (!win->m_hasVMT || gdk_event->window != gtk_widget_get_window(widget))
+    if (gdk_event->window != gtk_widget_get_window(widget))
         return false;
     if (g_blockEventsOnDrag) return TRUE;
     if (g_blockEventsOnScroll) return TRUE;
@@ -340,6 +339,15 @@ static unsigned char close_bits[]={
 
 IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame,wxFrame)
 
+wxMiniFrame::~wxMiniFrame()
+{
+    if (m_widget)
+    {
+        GtkWidget* eventbox = gtk_bin_get_child(GTK_BIN(m_widget));
+        GTKDisconnect(eventbox);
+    }
+}
+
 bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
       const wxPoint &pos, const wxSize &size,
       long style, const wxString &name )
index 906867c25415689f1bebe3d075122f6cfbf11274..5bbdc930b815ccc555ccdf5cd3c17aebe6c6b373 100644 (file)
@@ -292,6 +292,7 @@ int wxMessageDialog::ShowModal()
         gtk_window_present( GTK_WINDOW(m_parent->m_widget) );
 
     gint result = gtk_dialog_run(GTK_DIALOG(m_widget));
+    GTKDisconnect(m_widget);
     gtk_widget_destroy(m_widget);
     g_object_unref(m_widget);
     m_widget = NULL;
index d95d98094d9d49a4c719114ac3d328866649c44d..91cb1ce6139c3bfa77ee22754dadbb765aa6a08a 100644 (file)
@@ -125,6 +125,7 @@ void wxNativeContainerWindow::OnNativeDestroyed()
     // because it's a private GDK function and calling normal
     // gdk_window_destroy() results in X errors while nulling just the window
     // pointer and destroying m_widget results in many GTK errors
+    GTKDisconnect(m_widget);
     m_widget = NULL;
 
     // notice that we intentionally don't use Close() nor Delete() here as our
index 6cfbcad491203094b7a691843ccc83cd9436e120..cc0b114c32b8b540ec86ff7f5bef0c40a4665179 100644 (file)
@@ -58,7 +58,6 @@ extern bool          g_blockEventsOnDrag;
 extern "C" {
 static void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioBox *rb )
 {
-    if (!rb->m_hasVMT) return;
     if (g_blockEventsOnDrag) return;
 
     if (!gtk_toggle_button_get_active(button)) return;
@@ -78,7 +77,6 @@ static void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioBo
 extern "C" {
 static gint gtk_radiobox_keypress_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxRadioBox *rb )
 {
-    if (!rb->m_hasVMT) return FALSE;
     if (g_blockEventsOnDrag) return FALSE;
 
     if ( ((gdk_event->keyval == GDK_Tab) ||
@@ -319,6 +317,7 @@ wxRadioBox::~wxRadioBox()
     while (node)
     {
         GtkWidget *button = GTK_WIDGET( node->GetData()->button );
+        GTKDisconnect(button);
         gtk_widget_destroy( button );
         node = node->GetNext();
     }
index a0d1b92d2c3900e446b0bb3d6d0ae090a7090609..421d84257599467aa457afca26dfd88ee147d95c 100644 (file)
@@ -32,8 +32,6 @@ extern "C" {
 static
 void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioButton *rb )
 {
-    if (!rb->m_hasVMT) return;
-
     if (g_blockEventsOnDrag) return;
 
     if (!gtk_toggle_button_get_active(button)) return;
index 78f0d118089c74c7bc771ec78d0e928a96291c49..c20ee70c5a7c756384d8cafbe857e59fc3532259 100644 (file)
@@ -129,7 +129,7 @@ gtk_value_changed(GtkRange* range, wxSlider* win)
     const double oldPos = win->m_pos;
     win->m_pos = value;
 
-    if (!win->m_hasVMT || g_blockEventsOnDrag)
+    if (g_blockEventsOnDrag)
         return;
 
     if (win->GTKEventsDisabled())
@@ -275,10 +275,13 @@ static gchar* gtk_format_value(GtkScale*, double value, void*)
 
 wxSlider::wxSlider()
 {
-    m_pos = 0;
-    m_scrollEventType = GTK_SCROLL_NONE;
-    m_needThumbRelease = false;
-    m_blockScrollEvent = false;
+    m_scale = NULL;
+}
+
+wxSlider::~wxSlider()
+{
+    if (m_scale && m_scale != m_widget)
+        GTKDisconnect(m_scale);
 }
 
 bool wxSlider::Create(wxWindow *parent,
@@ -294,6 +297,8 @@ bool wxSlider::Create(wxWindow *parent,
 {
     m_pos = value;
     m_scrollEventType = GTK_SCROLL_NONE;
+    m_needThumbRelease = false;
+    m_blockScrollEvent = false;
 
     if (!PreCreation( parent, pos, size ) ||
         !CreateBase( parent, id, pos, size, style, validator, name ))
index 52e8d4ce8f273f4c18af14ee8f4faa438daecfe2..5cb5b6bb897a175a0f4967a3df2f3faa44f4ffef 100644 (file)
@@ -38,7 +38,7 @@ gtk_value_changed(GtkSpinButton* spinbutton, wxSpinButton* win)
     const double value = gtk_spin_button_get_value(spinbutton);
     const int pos = int(value);
     const int oldPos = win->m_pos;
-    if (!win->m_hasVMT || g_blockEventsOnDrag || pos == oldPos)
+    if (g_blockEventsOnDrag || pos == oldPos)
     {
         win->m_pos = pos;
         return;
index aed0313357efabedf4b38c0cd26c892cb54a4add..e7b798197a07cefff7eef76f1273c86432d7563d 100644 (file)
@@ -39,7 +39,7 @@ extern "C" {
 static void
 gtk_value_changed(GtkSpinButton* spinbutton, wxSpinCtrlGTKBase* win)
 {
-    if (!win->m_hasVMT || g_blockEventsOnDrag)
+    if (g_blockEventsOnDrag)
         return;
 
     if (wxIsKindOf(win, wxSpinCtrl))
@@ -69,9 +69,6 @@ extern "C" {
 static void
 gtk_changed(GtkSpinButton* spinbutton, wxSpinCtrl* win)
 {
-    if (!win->m_hasVMT)
-        return;
-
     wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->GetId() );
     event.SetEventObject( win );
     event.SetString(gtk_entry_get_text(GTK_ENTRY(spinbutton)));
index 95f27a18fd2ec57139a6944bbb21a9a88a32677f..dda27477f3c888562d019f505299460a27a8aaa8 100644 (file)
@@ -546,8 +546,6 @@ gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win )
     if ( win->IgnoreTextUpdate() )
         return;
 
-    if (!win->m_hasVMT) return;
-
     if ( win->MarkDirtyOnChange() )
         win->MarkDirty();
 
@@ -607,12 +605,18 @@ void wxTextCtrl::Init()
     SetUpdateFont(false);
 
     m_text = NULL;
+    m_buffer = NULL;
     m_showPositionOnThaw = NULL;
     m_anonymousMarkList = NULL;
 }
 
 wxTextCtrl::~wxTextCtrl()
 {
+    if (m_text)
+        GTKDisconnect(m_text);
+    if (m_buffer)
+        GTKDisconnect(m_buffer);
+
     // this is also done by wxWindowGTK dtor, but has to be done here so our
     // DoThaw() override is called
     while (IsFrozen())
index 0589a9b70da967f717f5d568c34207a78cd80f6b..1ad831108f722b2d0940672ffb5be01132251d2d 100644 (file)
@@ -29,7 +29,7 @@ extern bool      g_blockEventsOnDrag;
 extern "C" {
 static void gtk_togglebutton_clicked_callback(GtkWidget *WXUNUSED(widget), wxToggleButton *cb)
 {
-    if (!cb->m_hasVMT || g_blockEventsOnDrag)
+    if (g_blockEventsOnDrag)
         return;
 
     // Generate a wx event.
index 99119fa8964d9ef03f8ade707b58703ebd712433..4ca00b32be3416a0fdb87cdb8230703d4ec25913 100644 (file)
@@ -269,7 +269,7 @@ gtk_frame_configure_callback( GtkWidget* widget,
                               GdkEventConfigure *WXUNUSED(event),
                               wxTopLevelWindowGTK *win )
 {
-    if (!win->m_hasVMT || !win->IsShown())
+    if (!win->IsShown())
         return FALSE;
 
     wxPoint point;
index 843b5a016436166ba4e8681942a25ba92d4dabf1..28754d298a52abcf6e042df368359eccf302f59b 100644 (file)
@@ -33,11 +33,6 @@ 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;
@@ -391,6 +386,11 @@ wxgtk_webview_webkit_resource_req(WebKitWebView *,
 
 wxIMPLEMENT_DYNAMIC_CLASS(wxWebViewWebKit, wxWebView);
 
+wxWebViewWebKit::wxWebViewWebKit()
+{
+    m_web_view = NULL;
+}
+
 bool wxWebViewWebKit::Create(wxWindow *parent,
                       wxWindowID id,
                       const wxString &url,
@@ -456,11 +456,8 @@ bool wxWebViewWebKit::Create(wxWindow *parent,
 
 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();
+    if (m_web_view)
+        GTKDisconnect(m_web_view);
 }
 
 bool wxWebViewWebKit::Enable( bool enable )
index d5352509f4ff1e7bb1cd936487e38389e12da68d..25429853798311ab146dcfabca28fb3413a2b374 100644 (file)
@@ -950,8 +950,6 @@ gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget),
                                GdkEventKey *gdk_event,
                                wxWindow *win )
 {
-    if (!win->m_hasVMT)
-        return FALSE;
     if (g_blockEventsOnDrag)
         return FALSE;
 
@@ -1124,9 +1122,6 @@ gtk_window_key_release_callback( GtkWidget * WXUNUSED(widget),
                                  GdkEventKey *gdk_event,
                                  wxWindowGTK *win )
 {
-    if (!win->m_hasVMT)
-        return FALSE;
-
     if (g_blockEventsOnDrag)
         return FALSE;
 
@@ -1276,13 +1271,11 @@ bool wxWindowGTK::GTKProcessEvent(wxEvent& event) const
 
 bool wxWindowGTK::GTKShouldIgnoreEvent() const
 {
-    return !m_hasVMT || g_blockEventsOnDrag;
+    return g_blockEventsOnDrag;
 }
 
 int wxWindowGTK::GTKCallbackCommonPrologue(GdkEventAny *event) const
 {
-    if (!m_hasVMT)
-        return FALSE;
     if (g_blockEventsOnDrag)
         return TRUE;
     if (g_blockEventsOnScroll)
@@ -2191,8 +2184,6 @@ void wxWindowGTK::Init()
     m_width = 0;
     m_height = 0;
 
-    m_hasVMT = false;
-
     m_showOnIdle = false;
 
     m_noExpose = false;
@@ -2359,6 +2350,12 @@ bool wxWindowGTK::Create( wxWindow *parent,
     return true;
 }
 
+void wxWindowGTK::GTKDisconnect(void* instance)
+{
+    g_signal_handlers_disconnect_matched(instance,
+        GSignalMatchType(G_SIGNAL_MATCH_DATA), 0, 0, NULL, NULL, this);
+}
+
 wxWindowGTK::~wxWindowGTK()
 {
     SendDestroyEvent();
@@ -2371,23 +2368,14 @@ wxWindowGTK::~wxWindowGTK()
     if ( gs_deferredFocusOut == this )
         gs_deferredFocusOut = NULL;
 
-    m_hasVMT = false;
+    if (m_widget)
+        GTKDisconnect(m_widget);
+    if (m_wxwindow && m_wxwindow != m_widget)
+        GTKDisconnect(m_wxwindow);
 
     // destroy children before destroying this window itself
     DestroyChildren();
 
-    // unhook focus handlers to prevent stray events being
-    // propagated to this (soon to be) dead object
-    if (m_focusWidget != NULL)
-    {
-        g_signal_handlers_disconnect_by_func (m_focusWidget,
-                                              (gpointer) gtk_window_focus_in_callback,
-                                              this);
-        g_signal_handlers_disconnect_by_func (m_focusWidget,
-                                              (gpointer) gtk_window_focus_out_callback,
-                                              this);
-    }
-
     if (m_widget)
         Show( false );
 
@@ -2564,8 +2552,6 @@ void wxWindowGTK::PostCreation()
 
     InheritAttributes();
 
-    m_hasVMT = true;
-
     SetLayoutDirection(wxLayout_Default);
 
     // unless the window was created initially hidden (i.e. Hide() had been
@@ -2610,13 +2596,6 @@ void wxWindowGTK::ConnectWidget( GtkWidget *widget )
                       G_CALLBACK (gtk_window_leave_callback), this);
 }
 
-bool wxWindowGTK::Destroy()
-{
-    m_hasVMT = false;
-
-    return wxWindowBase::Destroy();
-}
-
 static GSList* gs_queueResizeList;
 
 extern "C" {
@@ -4571,7 +4550,7 @@ wxEventType wxWindowGTK::GTKGetScrollEventType(GtkRange* range)
     // update current position
     m_scrollPos[barIndex] = value;
     // If event should be ignored, or integral position has not changed
-    if (!m_hasVMT || g_blockEventsOnDrag || wxRound(value) == wxRound(oldPos))
+    if (g_blockEventsOnDrag || wxRound(value) == wxRound(oldPos))
     {
         return wxEVT_NULL;
     }