Relax the sizer parent check to allow for null parent too
Normally non-toplevel windows must have non-null parents, as creating them with null parent would fail, but our own wxTabFrame used in AUI is an example of a window which can have null parent because it's actually never created at all. This does look like a pretty bad hack, but it's very unlikely to happen accidentally, so relax the assertion check added in the previous commit to allow for it.
This commit is contained in:
@@ -187,6 +187,17 @@ wxString MakeFlagsCheckMessage(const char* start, const char* whatToRemove)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CheckExpectedParentIs(wxWindow* w, wxWindow* expectedParent)
|
||||||
|
{
|
||||||
|
// We specifically exclude the case of a window with a null parent as it
|
||||||
|
// typically doesn't happen accidentally, but does happen intentionally in
|
||||||
|
// our own wxTabFrame which is a hack used by AUI for whatever reason, and
|
||||||
|
// could presumably be also done on purpose in application code.
|
||||||
|
wxWindow* const parent = w->GetParent();
|
||||||
|
|
||||||
|
return !parent || parent == expectedParent;
|
||||||
|
}
|
||||||
|
|
||||||
wxString MakeExpectedParentMessage(wxWindow* w, wxWindow* expectedParent)
|
wxString MakeExpectedParentMessage(wxWindow* w, wxWindow* expectedParent)
|
||||||
{
|
{
|
||||||
return wxString::Format
|
return wxString::Format
|
||||||
@@ -249,7 +260,7 @@ wxString MakeExpectedParentMessage(wxWindow* w, wxWindow* expectedParent)
|
|||||||
#define ASSERT_WINDOW_PARENT_IS(w, expectedParent) \
|
#define ASSERT_WINDOW_PARENT_IS(w, expectedParent) \
|
||||||
wxASSERT_MSG \
|
wxASSERT_MSG \
|
||||||
( \
|
( \
|
||||||
w->GetParent() == expectedParent, \
|
CheckExpectedParentIs(w, expectedParent), \
|
||||||
MakeExpectedParentMessage(w, expectedParent) \
|
MakeExpectedParentMessage(w, expectedParent) \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user