Fix hang when reparenting a frozen window in wxOSX

The wrong order of changing parent and freezing/thawing could result in
hanging the application when reparenting frozen windows, e.g. when
switching order of pages in a notebook.

Closes #16722.
This commit is contained in:
sbrowne
2017-12-03 00:15:03 +01:00
committed by Vadim Zeitlin
parent 0eb456f08e
commit d3f20c3837
2 changed files with 63 additions and 5 deletions

View File

@@ -1638,6 +1638,15 @@ void wxWindowMac::RemoveChild( wxWindowBase *child )
if ( child == m_growBox )
m_growBox = NULL ;
#endif
if (!child->IsBeingDeleted() && !child->IsTopLevel())
{
// Must be removed prior to RemoveChild and next AddChild call
// Otherwise the next AddChild may freeze the wrong window
wxWindowMac *mac = (wxWindowMac *)child;
if (mac->GetPeer() && mac->GetPeer()->IsOk())
mac->GetPeer()->RemoveFromParent();
}
wxWindowBase::RemoveChild( child ) ;
}
@@ -2458,10 +2467,9 @@ bool wxWindowMac::Reparent(wxWindowBase *newParentBase)
if ( !wxWindowBase::Reparent(newParent) )
return false;
GetPeer()->RemoveFromParent();
GetPeer()->Embed( GetParent()->GetPeer() );
MacChildAdded();
GetParent()->MacChildAdded();
return true;
}