Disable sizer flag checks if WXSUPPRESS_SIZER_FLAGS_CHECK is set
This provides a less intrusive, and also usable by the end users rather than only by the developers, way of doing the same thing as the just added wxSizerFlags::DisableConsistencyChecks() does.
This commit is contained in:
@@ -27,7 +27,9 @@ Changes in behaviour not resulting in compilation errors
|
|||||||
- Using invalid flags with wxBoxSizer or wxGridSizer items now triggers asserts
|
- Using invalid flags with wxBoxSizer or wxGridSizer items now triggers asserts
|
||||||
when done from the code or error messages when done in XRC. These asserts are
|
when done from the code or error messages when done in XRC. These asserts are
|
||||||
best avoided by fixing the flags, but wxSizerFlags::DisableConsistencyChecks()
|
best avoided by fixing the flags, but wxSizerFlags::DisableConsistencyChecks()
|
||||||
can be used to globally suppress them until this can be done.
|
can be used to globally suppress them until this can be done. Even less
|
||||||
|
intrusively, environment variable WXSUPPRESS_SIZER_FLAGS_CHECK can be set (to
|
||||||
|
any value) to achieve the same effect.
|
||||||
|
|
||||||
- wxWS_EX_VALIDATE_RECURSIVELY is now the default behaviour, i.e. calling
|
- wxWS_EX_VALIDATE_RECURSIVELY is now the default behaviour, i.e. calling
|
||||||
Validate() or TransferData{From,To}Window() will now also call the same
|
Validate() or TransferData{From,To}Window() will now also call the same
|
||||||
|
@@ -32,5 +32,10 @@ wxWidgets programs.
|
|||||||
set it to @c "CURL" to force using libcurl-based implementation under
|
set it to @c "CURL" to force using libcurl-based implementation under
|
||||||
MSW or macOS platforms where the native implementation would be chosen
|
MSW or macOS platforms where the native implementation would be chosen
|
||||||
by default.}
|
by default.}
|
||||||
|
@itemdef{WXSUPPRESS_SIZER_FLAGS_CHECK,
|
||||||
|
If set, disables asserts about using invalid sizer flags in the code.
|
||||||
|
This can be helpful when running older programs recompiled with
|
||||||
|
wxWidgets 3.1 or later, as these asserts are mostly harmless and can
|
||||||
|
be safely ignored if the code works as expected.}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@@ -1499,6 +1499,10 @@ public:
|
|||||||
using this function, especially permanently, rather than a temporary
|
using this function, especially permanently, rather than a temporary
|
||||||
workaround, is @e not recommended.
|
workaround, is @e not recommended.
|
||||||
|
|
||||||
|
Notice that the same effect as calling this function can be achieved by
|
||||||
|
setting the environment variable @c WXSUPPRESS_SIZER_FLAGS_CHECK to any
|
||||||
|
value.
|
||||||
|
|
||||||
@since 3.1.6
|
@since 3.1.6
|
||||||
*/
|
*/
|
||||||
static void DisableConsistencyChecks();
|
static void DisableConsistencyChecks();
|
||||||
|
@@ -147,7 +147,23 @@ static const int SIZER_FLAGS_MASK =
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
bool gs_disableFlagChecks = false;
|
int gs_disableFlagChecks = -1;
|
||||||
|
|
||||||
|
// Check condition taking gs_disableFlagChecks into account.
|
||||||
|
//
|
||||||
|
// Note that because this is not a macro, the condition is always evaluated,
|
||||||
|
// even if gs_disableFlagChecks is 0, but this shouldn't matter because the
|
||||||
|
// conditions used with this function are just simple bit checks.
|
||||||
|
bool CheckSizerFlags(bool cond)
|
||||||
|
{
|
||||||
|
// Once-only initialization: check if disabled via environment.
|
||||||
|
if ( gs_disableFlagChecks == -1 )
|
||||||
|
{
|
||||||
|
gs_disableFlagChecks = wxGetEnv("WXSUPPRESS_SIZER_FLAGS_CHECK", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return gs_disableFlagChecks || cond;
|
||||||
|
}
|
||||||
|
|
||||||
wxString MakeFlagsCheckMessage(const char* start, const char* whatToRemove)
|
wxString MakeFlagsCheckMessage(const char* start, const char* whatToRemove)
|
||||||
{
|
{
|
||||||
@@ -159,6 +175,9 @@ wxString MakeFlagsCheckMessage(const char* start, const char* whatToRemove)
|
|||||||
"please ignore this message, it is harmless, and please try "
|
"please ignore this message, it is harmless, and please try "
|
||||||
"reporting the problem to the program developers.\n"
|
"reporting the problem to the program developers.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
"You may also set WXSUPPRESS_SIZER_FLAGS_CHECK environment "
|
||||||
|
"variable to suppress all such checks when running this program.\n"
|
||||||
|
"\n"
|
||||||
"If you're the developer, simply remove %s from your code to "
|
"If you're the developer, simply remove %s from your code to "
|
||||||
"avoid getting this message. You can also call "
|
"avoid getting this message. You can also call "
|
||||||
"wxSizerFlags::DisableConsistencyChecks() to globally disable "
|
"wxSizerFlags::DisableConsistencyChecks() to globally disable "
|
||||||
@@ -175,7 +194,7 @@ wxString MakeFlagsCheckMessage(const char* start, const char* whatToRemove)
|
|||||||
#define ASSERT_NO_IGNORED_FLAGS_IMPL(f, value, name, explanation) \
|
#define ASSERT_NO_IGNORED_FLAGS_IMPL(f, value, name, explanation) \
|
||||||
wxASSERT_MSG \
|
wxASSERT_MSG \
|
||||||
( \
|
( \
|
||||||
gs_disableFlagChecks || !((f) & (value)), \
|
CheckSizerFlags(!((f) & (value))), \
|
||||||
MakeFlagsCheckMessage \
|
MakeFlagsCheckMessage \
|
||||||
( \
|
( \
|
||||||
name " will be ignored in this sizer: " explanation, \
|
name " will be ignored in this sizer: " explanation, \
|
||||||
@@ -189,7 +208,7 @@ wxString MakeFlagsCheckMessage(const char* start, const char* whatToRemove)
|
|||||||
#define ASSERT_INCOMPATIBLE_NOT_USED_IMPL(f, f1, n1, f2, n2) \
|
#define ASSERT_INCOMPATIBLE_NOT_USED_IMPL(f, f1, n1, f2, n2) \
|
||||||
wxASSERT_MSG \
|
wxASSERT_MSG \
|
||||||
( \
|
( \
|
||||||
gs_disableFlagChecks || ((f) & (f1 | f2)) != (f1 | f2), \
|
CheckSizerFlags(((f) & (f1 | f2)) != (f1 | f2)), \
|
||||||
MakeFlagsCheckMessage \
|
MakeFlagsCheckMessage \
|
||||||
( \
|
( \
|
||||||
"One of " n1 " and " n2 " will be ignored in this sizer: " \
|
"One of " n1 " and " n2 " will be ignored in this sizer: " \
|
||||||
@@ -1527,9 +1546,11 @@ wxSizerItem *wxGridSizer::DoInsert(size_t index, wxSizerItem *item)
|
|||||||
// Check that expansion will happen in at least one of the directions.
|
// Check that expansion will happen in at least one of the directions.
|
||||||
wxASSERT_MSG
|
wxASSERT_MSG
|
||||||
(
|
(
|
||||||
gs_disableFlagChecks ||
|
CheckSizerFlags
|
||||||
!(flags & (wxALIGN_BOTTOM | wxALIGN_CENTRE_VERTICAL)) ||
|
(
|
||||||
!(flags & (wxALIGN_RIGHT | wxALIGN_CENTRE_HORIZONTAL)),
|
!(flags & (wxALIGN_BOTTOM | wxALIGN_CENTRE_VERTICAL)) ||
|
||||||
|
!(flags & (wxALIGN_RIGHT | wxALIGN_CENTRE_HORIZONTAL))
|
||||||
|
),
|
||||||
MakeFlagsCheckMessage
|
MakeFlagsCheckMessage
|
||||||
(
|
(
|
||||||
"wxEXPAND flag will be overridden by alignment flags",
|
"wxEXPAND flag will be overridden by alignment flags",
|
||||||
|
Reference in New Issue
Block a user