This function is called from wxWindowBase dtor to detach the window
being destroyed from the containing sizer and casting the pointer to the
object to wxWindow is UB because the object is not actually a wxWindow
any more by then.
Remove the cast and pass wxWindowBase pointer to wxSizer::Detach()
instead, as it doesn't need the full wxWindow anyhow.
Also document that any wxSizer-derived classes overriding Detach() will
need to be modified to follow this change.
Using static_cast<className*>(obj) when the object is not actually of
the given type is UB, so avoid it even if should be harmless in
practice, by simply omitting it: we only need "obj" to be a wxObject
here.
Note that this means that using wxCheckCast() or wxStaticCast() with a
type not deriving from wxObject is always UB, but there is not much that
we can do about it, so just document this explicitly.
This is very similar to the parent commit and does the same thing for
m_frameToolBar, which is now managed by the frame itself, instead of
wxToolBar, as the other commit did for m_frameStatusBar.
Don't rely on wxStatusBar dtor resetting the frame status bar, this was
awkward (because the frame should be responsible for maintaining its own
state, instead of letting other classes do it) and resulted in UB when
the status bar was deleted from wxFrameBase dtor, as the cast of its
parent pointer to wxFrame was invalid by then, as the half-destructed
frame wasn't a wxFrame any more.
This cast was invalid, as the pointer could not be a valid pointer to a
wxWindow any more when this function was called from (child window)
wxWindowBase dtor.
It also was completely unnecessary, so just remove it.
By default, UBSAN doesn't stop the program and so the exit code is still
0 even if errors are detected, so set halt_on_error=1 in UBSAN_OPTIONS
to change this.
But also still rerun the tests normally, without halting, to detect all
UB occurrences if there is more than one instance of it.
Code in UTF-16/32 conversions reinterpreted char pointers as pointers to
uint16_t/uint32_t which is invalid, in general, as the char pointer may
not be sufficiently aligned.
Stop doing this and reconstruct the 16/32-bit values from bytes
manually, taking care of the encoding endianness.
Even though wxCONV_FAILED and wxNO_LEN happen to have the same value, we
must return the latter and not the former from GetLength() to indicate
an error, according both to its comment and common sense.
Don't shift signed integer which can be negative, cast it to unsigned
first: as we shift it by 32 bits, it doesn't matter that it is not
sign-extended in this case.
In build with wxUSE_SECRETSTORE==0 the stand-in implementation of
wxSecretStore was broken (instead of just being insecure) because
objects of this type were never valid, as we forgot to set m_valid.
Thanks UBSAN for flagging access to this uninitialized variable.
Under certain circumstances it can make sense to use a locale other than
the default user locale.
One example would be, if an application wants to use a UI translation
with an RTL language (like Arabic) on a non-RTL system. This wouldn't
work with the default locale, because the layout direction would be
wrong.
Currently setting a non-default locale can already be achieved via
wxLocale anyway. Therefore wxUILocale::UseLocaleName() should be made
public, to allow for less side effects than using wxLocale.
Closes#23972.
Use the locale set using wxUILocale or the equivalent of the default "C"
locale (en-US) in the native date picker control instead of always using
the default user locale.
Closes#23956.
The list of the languages to install the message catalogs for has to be
hardcoded in the bakefile currently, so update it to ensure that all the
available catalogs are installed.
Fixes#24880.
Closes#24887.
All supported platforms provide 64-bit integer types since many years,
so remove the legacy wxLongLongWx implementation and rename
wxLongLongNative to just wxLongLong and always compile it in.
Note that wxLongLong itself must still be kept for compatibility as it
has member functions, such as GetValue() or ToString(), that can be used
in the existing code.
This was used for Borland compatibility which was removed back in
a6d4799de9 (Remove BCC-specific conditionally compiled code, 2020-10-13)
making this macro unnecessary and comment before it confusing because it
didn't make sense any more.
Rename some local variables and parameters to avoid shadowing the member
variables.
Notably avoid shadowing QWidget::data in QWidget-derived class.
No real changes.
Always initialize the variables that were previously only initialized in
the case when they were really used -- this doesn't cost much and avoids
MSVC warnings about these variables being possibly uninitialized.
If icon theme has only SVG files, lookup excluding SVG may result in a builtin icon using
a resource path which is not a valid file path. Avoid this by allowing SVG in this case.
See #23775
This ensures that restoring the layout by recreating the same docks
recreates the same geometry as was used before, while without it the
panes just got their default initial sizes instead.
Ideal would be to avoid serializing the docks at all, as they can be
recreated automatically to accommodate the panes, but currently there is
no way to specify the size for the docks being recreated, so instead we
have to recreate it with the correct size ourselves when deserializing.
Although this is unusual in wxWidgets API, it really makes sense to let
wxAuiManager perform the scaling, if necessary, instead of asking every
implementation of wxAuiSerializer and wxAuiDeserializer to do it on
their own, so pass the values as DIPs to the former and assume the
values returned by the latter are in DIPs too to make things just work
even on the platforms where DIPs are not natively used (i.e. wxMSW).
Add wxAuiSerializer and wxAuiDeserializer classes and SaveLayout() and
LoadLayout() functions in wxAuiManager using them.
Show how these classes can be used to use XML for storing AUI layout in
the sample.
See #24225.
The format of the generated JSON by the httpbin service for
multiple headers with the same name differs between platforms.
These headers are sometimes put into a JSON array and sometimes
concatenated into a single comma-separated string.
Some code duplication can be removed by using
wxWinHTTPQueryAllHeaderStrings() in wxWinHTTPQueryHeaderString()
and returning ony the last queried header. This change also
increases consistency accross all webrequest implementations to
prefer the last header over the first in ambiguities.