diff options
author | Jiří Techet <techet@gmail.com> | 2015-11-06 16:52:59 +0100 |
---|---|---|
committer | Jiří Techet <techet@gmail.com> | 2015-11-06 16:52:59 +0100 |
commit | c65cb15475dcdfe35980c6008b515eb811b7c8e0 (patch) | |
tree | 558d8082e4e5a3433dd9d1ed611720bee6f755ac | |
parent | 8546c62e8ffaa0312d0fb31e3d57150f1704c396 (diff) | |
download | scintilla-mirror-c65cb15475dcdfe35980c6008b515eb811b7c8e0.tar.gz |
Unparent scrollbars in dispose on GTK
Dispose should be used to remove references to objects that might
point to the destructed object. This is the case of scrollbars whose
parent is ScintillaGtk and which internally hold pointers to it.
This eliminates warnings on OS X.
-rw-r--r-- | gtk/ScintillaGTK.cxx | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index 25e3587ab..ce02e09ca 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -302,6 +302,7 @@ private: static void StyleSetText(GtkWidget *widget, GtkStyle *previous, void*); static void RealizeText(GtkWidget *widget, void*); + static void Dispose(GObject *object); static void Destroy(GObject *object); static void SelectionReceived(GtkWidget *widget, GtkSelectionData *selection_data, guint time); @@ -2583,6 +2584,27 @@ void ScintillaGTK::RealizeText(GtkWidget *widget, void*) { static GObjectClass *scintilla_class_parent_class; +void ScintillaGTK::Dispose(GObject *object) { + try { + ScintillaObject *scio = reinterpret_cast<ScintillaObject *>(object); + ScintillaGTK *sciThis = reinterpret_cast<ScintillaGTK *>(scio->pscin); + + if (PWidget(sciThis->scrollbarv)) { + gtk_widget_unparent(PWidget(sciThis->scrollbarv)); + sciThis->scrollbarv = NULL; + } + + if (PWidget(sciThis->scrollbarh)) { + gtk_widget_unparent(PWidget(sciThis->scrollbarh)); + sciThis->scrollbarh = NULL; + } + + scintilla_class_parent_class->dispose(object); + } catch (...) { + // Its dying so nowhere to save the status + } +} + void ScintillaGTK::Destroy(GObject *object) { try { ScintillaObject *scio = SCINTILLA(object); @@ -2594,9 +2616,6 @@ void ScintillaGTK::Destroy(GObject *object) { //Platform::DebugPrintf("Destroying %x %x\n", sciThis, object); sciThis->Finalise(); - gtk_widget_unparent(PWidget(sciThis->scrollbarv)); - gtk_widget_unparent(PWidget(sciThis->scrollbarh)); - delete sciThis; scio->pscin = 0; scintilla_class_parent_class->finalize(object); @@ -3112,6 +3131,7 @@ void ScintillaGTK::ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_ // of the signal handlers here (those that currently attached to wDraw // in Initialise() may require coordinate translation?) + object_class->dispose = Dispose; object_class->finalize = Destroy; #if GTK_CHECK_VERSION(3,0,0) widget_class->get_preferred_width = GetPreferredWidth; |