Reset m_pMainWnd in wxMFCApp::ExitInstance() to avoid crash when
deleting it again in OnMainWindowDestroyed() that could happen if
ExitInstance() was called not because the main window was closed (normal
case) but because wxApp::ExitMainLoop() was called, as it happens when
an unhandled exception is thrown.
If wxApp::OnExceptionInMainLoop() returns false, we're supposed to exit
the application by stopping its main event loop, not the loop that is
currently running, so do the former instead of the latter.
Also call wxAbort() if we can't exit the application in any other way,
this is not ideal, but still better than not doing anything and, for
example, keeping showing the same "Unexpected error occurred" message
box to the user over and over again if the exception comes from an event
handler being called repeatedly, such as wxEVT_PAINT or wxEVT_IDLE.
GTK+ 3 (but not the generic version nor even GTK+ 2, apparently) sends
"selection changed" event from gtk_tree_model_row_deleted() when
deleting the currently selected row, which resulted in sending of
wxEVT_TREELIST_SELECTION_CHANGED events with invalid wxTreeListItem,
containing a dangling pointer, and a crash in the treelist sample when
trying to dump it.
Avoid this by clearing the model (and hence generating these events)
first and deleting the items only afterwards.
Also add a trivial unit test for wxTreeListCtrl::DeleteAllItems(), which
doesn't even allow to reproduce this bug, but is still probably better
to have than not to.
Closes#18045.
Checking that a pointer is non-null before dereferencing it is perfectly
useless: the code will crash anyhow, so assert doesn't help with
debugging it in debug builds nor with preventing the crash in release.
SetHasChildren(true) must be called before checking GetChildNodes() if
the parent hadn't had any items in the initial model.
Also remove the assert checking that the node is open in
BuildTreeHelper() as we may need to build even a closed tree branch.
Calling ItemAdded() on a parent item that had never been opened yet
"lost" all its children that initially existed in the model, as the
corresponding subtree wasn't built any more in Expand() when this item
was finally opened because the list of item children wasn't empty any
more after ItemAdded() added the new child to it.
Fix this by simply not doing anything in ItemAdded() in this situation,
there is no need to update a closed tree branch immediately anyhow.
There doesn't seem to be any good reason for this, as it's perfectly
possible to use ellipsize the text if it's too long to fit even when the
control is resized to its maximal extent, but still allow the control to
resize in the first place.
See https://groups.google.com/d/msg/wx-dev/58xFP4FIxXc/d5lj6901CQAJ
Refactor wxStaticText code to use AutoResizeIfNecessary() for all the
updates done after the label extent changes (whether it's due to the
change of the label itself or the font used for rendering it).
There should be no changes in behaviour after this commit except for a
small bug fix in wxGenericStaticText when setting label with markup:
this didn't invalidate the best size before, but does now.
Recent optimizations avoiding resort on item change (see
https://github.com/wxWidgets/wxWidgets/pull/642) have also optimized
away refreshing the modified item, which was done implicitly, as a side
effect of resorting, before, so the changes were not reflected on
display immediately any longer.
Fix this by simply refreshing the item explicitly and also add a way to
test for the correct behaviour in the sample.
No real changes, just add the new DoItemChanged() used from both
ItemChanged() and ValueChanged() notifications to avoid repeating the
same code in both functions.
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.
Merge ctors from (width, height) and (width, height, scale) into a
single one because the former really should be just a special case of
the latter for scale == 1 but, surprisingly and confusingly it wasn't,
because the latter also multiplied the size by scale, meaning that width
and height parameters had different meanings.
This resulted in at least 3 bugs when using scale factors different from
1: first, copying bitmaps wasn't done correctly because as
wxBitmapRefData copy ctor incorrectly scaled its size by scale again.
And second, creating bitmap from wxImage whose size wasn't divisible by
scale not just didn't work correctly but crashed when accessing memory
outside of the image because (unnecessarily) dividing and multiplying
the image size by scale wasn't idempotent. Finally, even for the images
of even size (assuming scale factor of 2), bitmaps created from them
used incorrect width and height, corresponding to the half of the image
dimensions, instead of the same ones, as they're supposed to be (the
scaled dimensions are supposed to be returned by GetScale{Width,Height}
methods).
Closes#17505.
There is no need to handle this style specially here, it's supposed to
be handled at wxWindow level and is, indeed, at least in all the major
ports.
So revert 2119b213e3 (see #13616) and the
workaround for it applied later for macOS (see #14856). And this also
removes the need for handling wx[HV]SCROLL in wxScrolled (see #17846).
Closes#14856, #17846.
Several compilation fixes due to the fact that sizeof(long)==8 under
Cygwin in 64 bits.
This allows the library to compile, but there are still run-time
problems, notably the unit tests throw an unknown exception currently.
Even though we don't need to perform the checks for the availability of
<unordered_map> or <type_traits> headers when using C++11 because we can
safely assume they're indeed available, we still need to define the
corresponding symbols, as if the checks were performed, so that the code
inside and outside the library could test them in any case, whether
we're using C++11 or not.
When using configure, use the same family of hash sets/maps when
building wxWidgets and the applications using it as doing otherwise
results in ABI incompatibility.
Avoid showing message boxes even if we don't have the associated console
as this prevents the test from completing on its own if an unknown
exception happens.
This is another fix for 64 bit Cygwin build: LONG is defined as a 32 bit
type in it, but not long, which is 64 bits, so use the former instead of
the latter.
Due to the same problem with sizeof(long) mismatch as in the previous
commit, we can't use struct timeval, with its long fields, in 64 bit
Cygwin builds, and need to use __ms_timeval instead.
Add wxTimeVal_t type to hide this difference and update all code
compiled under MSW (there is no need to uglify Unix-only code using
timeval, as in wxSelectDispatcher, for example) to use it instead of
timeval.
Use __ms_u_long instead of just u_long with Cygwin to avoid mismatch
between (64 bit) Cygwin long and (still 32 bit, even in 64 bit build)
Windows API long.
Use __LONG32, which is always 32 bits when using Cygwin, unlike long,
which is 64 bits there in 64 bit builds, and so can't be used as an
argument to InterlockedExchange().
Closes#16746.
In some specific scenario, described in the newly added comment in
wxStaticBoxBase::Enable(), the box and its label could remain disabled
after its parent was disabled and re-enabled.
Fix this by continuing to use the derived class version for disabling
the box children, but not when enabling them, as the base class version
already does the right thing in this case.
Calling Enable() on all children from wxStaticBox::Enable() was wrong,
the actual status of the child, returned by wxWindow::IsThisEnabled(),
is not supposed to change just because its parent was disabled.
Call NotifyWindowOnEnableChange() to avoid this, while still disabling
the children visually.
Simplify the code by replacing 2 conditionally-compiled DoEnable() calls
with a single unconditional one.
This doesn't change the behaviour of Enable(), as it always called
DoEnable() on the window itself and only did it for its children when
wxHAS_NATIVE_ENABLED_MANAGEMENT was not defined before and continues to
do the same thing now, but it should fix a small bug in Reparent() as it
didn't update the actual status of the window if it changed as the
result of reparenting before, even though it was supposed to.
There doesn't seem to be any need to have this symbol in the header,
when it's only used in NotifyWindowOnEnableChange() in wincmn.cpp.
No real changes.
This reverts commit d26758044c which was a
workaround for the problem of wxWakeUpIdle() dispatching events, as this
is not the case any more after the latest changes.
It just forwards to (virtual) WakeUp() and there should be no need to
ever override this method itself (nor even to keep it, except for
backwards compatibility).
No real changes.
Since the switch to using an event object for idle handling wakeup,
WM_NULLs are not being sent any longer, so wxIdleWakeUpModule didn't do
anything, resulting in pending event dispatching being paused while our
event loop was not running, as it happened, for example, while the
window was resized.
See #17579.
This reverts commit ebb3a791b9,
effectively reapplying 6c40531fb7 once
again.
This breaks wake up when not running our own event loop once again
(see #17579), but this will be fixed in the next commit.
This can result in deadlocks because wxWakeUpIdle(), admittedly rather
unexpectedly, can result in dispatching a message in the main thread,
which could reacquire the same lock again.