Don't assert in focus code for buttons inside a wxPopupWindow
IsTopLevel() returns true for wxPopupWindow, even if it's not a subclass of wxTopLevelWindow, so GetTLWParentIfNotBeingDeleted() asserted when called with a button inside a wxPopupWindow. Just return null from it instead for now. A better solution could be to return wxNonOwnedWindow from GetTLWParentIfNotBeingDeleted() (which would need to be renamed to something more suitable) and move the {Get,Set}TmpDefaultItem() methods into it.
This commit is contained in:
@@ -252,28 +252,14 @@ wxWindow *wxButton::SetDefault()
|
|||||||
// return NULL
|
// return NULL
|
||||||
static wxTopLevelWindow *GetTLWParentIfNotBeingDeleted(wxWindow *win)
|
static wxTopLevelWindow *GetTLWParentIfNotBeingDeleted(wxWindow *win)
|
||||||
{
|
{
|
||||||
for ( ;; )
|
wxWindow* const parent = wxGetTopLevelParent(win);
|
||||||
{
|
wxASSERT_MSG( parent, wxT("button without top level parent?") );
|
||||||
// IsTopLevel() will return false for a wxTLW being deleted, so we also
|
|
||||||
// need the parent test for this case
|
if ( parent->IsBeingDeleted() )
|
||||||
wxWindow * const parent = win->GetParent();
|
|
||||||
if ( !parent || win->IsTopLevel() )
|
|
||||||
{
|
|
||||||
if ( win->IsBeingDeleted() )
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
break;
|
// Note that this may still return null for a button inside wxPopupWindow.
|
||||||
}
|
return wxDynamicCast(parent, wxTopLevelWindow);
|
||||||
|
|
||||||
win = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxASSERT_MSG( win, wxT("button without top level parent?") );
|
|
||||||
|
|
||||||
wxTopLevelWindow * const tlw = wxDynamicCast(win, wxTopLevelWindow);
|
|
||||||
wxASSERT_MSG( tlw, wxT("logic error in GetTLWParentIfNotBeingDeleted()") );
|
|
||||||
|
|
||||||
return tlw;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set this button as being currently default
|
// set this button as being currently default
|
||||||
|
Reference in New Issue
Block a user