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
This commit is contained in:
Vadim Zeitlin 2011-07-09 23:37:03 +00:00
parent cd9b34ef83
commit 0edbdf6a45

View File

@ -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) );