From 0edbdf6a45beed571efa0f6f1b5b4396d8932d36 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 9 Jul 2011 23:37:03 +0000 Subject: [PATCH] Check for GTK window parent, not wx one, when reparenting. A notebook page removed from its notebook can have a non-NULL wx parent but not have any parent at GTK level any longer, so test for the window parent at GTK level before removing the widget from it, otherwise we were getting GTK asserts when trying to remove a window from its no-more-parent. See #13305. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68213 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/window.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index b45d923700..23c4a3cbb9 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -3203,8 +3203,7 @@ bool wxWindowGTK::Reparent( wxWindowBase *newParentBase ) { wxCHECK_MSG( (m_widget != NULL), false, wxT("invalid window") ); - wxWindowGTK *oldParent = m_parent, - *newParent = (wxWindowGTK *)newParentBase; + wxWindowGTK * const newParent = (wxWindowGTK *)newParentBase; wxASSERT( GTK_IS_WIDGET(m_widget) ); @@ -3213,8 +3212,11 @@ bool wxWindowGTK::Reparent( wxWindowBase *newParentBase ) wxASSERT( GTK_IS_WIDGET(m_widget) ); - if (oldParent) - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(m_widget)), m_widget); + // Notice that old m_parent pointer might be non-NULL here but the widget + // still not have any parent at GTK level if it's a notebook page that had + // been removed from the notebook so test this at GTK level and not wx one. + if ( GtkWidget *parentGTK = gtk_widget_get_parent(m_widget) ) + gtk_container_remove(GTK_CONTAINER(parentGTK), m_widget); wxASSERT( GTK_IS_WIDGET(m_widget) ); -- 2.45.2