The change of 675728e1c0 (Fix crash when using wxDataObjectComposite
with bitmap in wxMSW, 2023-06-20) forgot to replace GetBitmap() call
with the local variable -- even if GetBitmap() returns the same thing,
as this local variable is just a reference to the member one which it
returns, it's more clear to use it here directly instead of using this
function and it was already done like this in GetDataHere(), so this is
also more consistent.
Disable warnings while compiling the tests to avoid unnecessary noise in
the CMake output/error files (because we don't really care about
warnings in the test code at all) and also, and more importantly, to
ensure that the tests don't fail even when -Werror is specified in the
CMAKE_CXX_FLAGS globally, as it may happen when wxWidgets is used via
add_subdirectory() from a superproject.
See #23665.
This is the standard and there doesn't seem to be any contemporary
systems where this is not the case. The configure check for it was
originally added in 101c20d554 (attempting to fix sa_handler signature
for IRIX, 2000-04-01), but IRIX is not supported/doesn't exist any
longer, so don't waste time on checking for this.
The real motivation for this change is that the test failed in CMake
builds, showing just
-- Performing Test wxTYPE_SA_HANDLER_IS_INT - Failed
in the log and then resulting in -fpermissive warnings when assigning
wxFatalSignalHandler to sa_handler and it's simpler to just remove the
check than to debug it.
See #23664.
Return the disabled bitmap and not the normal one.
This fixes a regression introduced in 9a5123afed (Use wxBitmapBundle in
wxAuiToolBar and wxAuiPaneInfo too, 2021-11-14).
Closes#23666.
Using strcpy() in GetDataHere() added an extra NUL at the end which
didn't fit into the buffer of the size returned by GetDataSize(). This
could have been also fixed by returning an extra byte from the latter
function, but as the string doesn't need to be NUL-terminated,
apparently, just use memcpy() with the correct number of bytes instead.
Also, because the string is not necessarily NUL-terminated, use the
provided length in wxHTMLDataObject::SetData() instead of relying on the
buffer being NUL-terminated and reading uninitialized memory beyond its
size.
Add a unit test confirming that there are no more ASAN errors when using
this class.
Closes#23660.
Co-Authored-By: mcorino <martin@corino.nl>
Instead of just adding 400 and leaving unused and uninitialized data in
the clipboard data, compute exactly the size of the data we need.
Also replace multiple strlen() calls that are not really needed because
we already know the various lengths.
Still NUL-terminate clipboard data because everybody else does it, even
if it's not totally clear if it is required.
Use StartFragment and EndFragment headers values in order to extract the
HTML fragment from the entire CF_HTML string, instead of searching for
"<!--StartFragment-->" and "<!--EndFragment-->" comments which could be
wrong (e.g. if a StartFragment comment actually appeared inside the HTML
fragment) and less efficient too.
Also add a simple pseudo-test, disabled by default, allowing to view the
clipboard contents if HTML is available on it.
Notable use the correct value for StartFragment: header which must
contain the start of the HTML fragment data and not the start of
"<--StartFragment-->" comment.
Also make this code simpler and more efficient by remembering the
offsets as we're creating the string instead of using strstr() to find
them later.
No other program does it and having these extra new lines means that our
own GetData() returns extra new lines compared to the value passed to
SetData().
When wxClipboard is destroyed as part of the program shutdown,
gdk_selection_owner_get() doesn't return our clipboard widget as owner
any more, so we don't reset the owner when Clear() is called and hence
never free the data.
Do it explicitly if we don't have clipboard ownership in Clear() any
longer to avoid memory leaks -- even though they are mostly harmless (as
they happen only once, on exit), they still show up in LSAN and similar
tools reports.
Revert the change introduced in b473163da2
and restore the setting of the background of delta-RLE bitmaps to the
first entry in the colour table. This retains earlier wxWidgets
behaviour and matches Windows `LoadImage()` with `LR_CREATEDIBSECTION`.
Closes#23638.
Closes#23657.
It doesn't make sense to keep the old and almost never used alternative
wxClipboard implementation which has known fatal bugs (such as casts of
wxDataObject that could be wxDataObjectComposite to wxBitmapDataObject,
see #23564) when wxUSE_OLE is never going to be disabled anyhow.
Note that this means wxSetClipboardData() function doesn't exist at all
any longer when previously it was available in the wxUSE_OLE==0 builds.
As the official builds always used wxUSE_OLE==1, this doesn't look like
a huge loss, but if needed, we could add it back later and reimplement
it in terms of wxClipboard::SetData().
This reverts the changes of b1fad4da44 (Convert 0RGB wxBitmaps to RGB
when copying them to clipboard, 2017-04-30) that added a cast from
wxDataObject to wxBitmapDataObject for any object supporting bitmaps,
which resulted in a crash when this happened to be wxDataObjectComposite
and not wxBitmapDataObject, and does the same thing in
wxBitmapDataObject itself which now converts 0RGB bitmaps to RGB ones
when asked for the bitmap data.
The main change is that the code using wxDataObjectComposite doesn't
crash any longer, but another nice side effect is that this is possibly
more efficient as well because the conversion could be skipped entirely
if the bitmap is never pasted.
See #17640.
Closes#23564.
This function should be used to get the parent for the custom controls
instead of relying on them being reparented under it by the code added
in the last commit.
Change the type of m_contents to be wxWindow and not wxPanel as it
doesn't really matter, but wxPanel is not fully declared in this header
while wxWindow is.
Existing code uses the dialog itself for the custom controls created in
this function, so make this work by reparenting them under m_contents.
This fixes an assert about the wrong parent window when showing a custom
about dialog in the dialogs sample.
Closes#23653.
This avoids crash if wxVSCROLL or wxHSCROLL is used with wxGLCanvas
which calls wxWindow::Create() after calling DontCreatePeer() because
the Create() tries to use the not (yet) existent peer in
MacCreateScrollBars().
Avoid this problem by moving the call to MacCreateScrollBars() to
MacPostControlCreate(), which doesn't change anything for the windows
that do not call DontCreatePeer(), but ensures that the peer already
exists by the time MacPostControlCreate() is called for those that do.
Closes#23536.
This was broken in ce1ee46 (Use wxRadioButton in MSW wxRadioBox
implementation, 2022-12-24), fix it by using a wxRadioButton subclass
processing just the cursor arrow keys but not TAB.
Closes#23647.
Now that we have wxRadioBoxButton we can simply store its index in it
and use it directly when it's clicked instead of finding the button in
m_radioButtons vector.
No real changes yet, just prepare for the upcoming commits by adding a
custom subclass that will be used by wxRadioBox instead of using
wxRadioButton directly.
It doesn't seem like it is meant to be overridden, so don't imply that
it should be possible to do it and make it non-virtual.
Also rename to DoTranslateBorder() to make it more clear that this is a
private function and not part of the public API.
Finally, improve its comment and never return wxBORDER_THEME from this
functions if themes support is off.
The default wxBORDER_SUNKEN uses 2px border and one of those pixels is
white, which is too light in the dark mode, so don't use it by default.
See #23622.
This function was added back in a047aff270 (Added wxBORDER_THEME,
wxWindow::GetDefaultBorderForControl(), wxWindow::CanApplyThemeBorder(),
2007-08-07) but seems to have been made completely unnecessary by
dc797d8e1b (More border rationalisation. GetDefaultBorder is now mostly
defined in base class files., 2007-11-13) soon afterwards and never did
anything other than returning wxBORDER_THEME, with no explanation as to
when it might be useful to override it not to do it.
It also doesn't seem to be really used anywhere outside wxWidgets and
has never been documented, so make it non-virtual and deprecate it to
avoid confusion and simplify things.
In the note about building wxWidgets with MinGW makefile and using
parallel build, explain that "-jN" option cannot be used when building
"setup_h" target.
Closes#23642.
We need to check for the column row to avoid generating an event with an
invalid index, which may result in a crash in the application code.
Closes#23636.
libwebkit2gtk-4.1 has the same API as libwebkit2gtk-4.0, except that the
former links with libsoup-3.0 and the latter links with libsoup-2.4.
Fixes#23630.