Commit graph

74910 commits

Author SHA1 Message Date
Vadim Zeitlin
72c5691d2f Fix buffer overrun in wxHTMLDataObject under non-MSW platforms
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>
2023-06-21 20:38:25 +01:00
Vadim Zeitlin
e4bec18505 Compute exact length needed for CF_HTML contents
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.
2023-06-21 20:38:25 +01:00
Vadim Zeitlin
c7d414bbed Make HTML pasting code more robust and efficient
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.
2023-06-21 20:38:25 +01:00
Vadim Zeitlin
355db874bc Fix offsets in HTML copied to clipboard
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.
2023-06-21 20:38:25 +01:00
Vadim Zeitlin
93729d8875 Remove extra new lines from HTML copied to clipboard
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().
2023-06-21 20:24:39 +01:00
Vadim Zeitlin
ede59ecb16 Add a symbolic constant for the offsets lengths too
Get rid of the last hardcoded number in CF_HTML code.
2023-06-21 20:24:39 +01:00
Vadim Zeitlin
649843a646 Use symbolic constants in CF_HTML-related code
No real changes, just use constants instead of a bunch of hardcoded
strings and numbers.
2023-06-21 20:24:39 +01:00
Vadim Zeitlin
1cf83980a2 Refactor wxHTMLDataObject to keep wxMSW-specific parts together
Also add a link to the official CF_HTML format documentation.

No real changes, just prepare for further ones.
2023-06-21 20:24:34 +01:00
Vadim Zeitlin
b52728a62a Fix memory leak of wxClipboard data on exit
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.
2023-06-21 18:19:15 +01:00
Brian Nixon
e1e2e982e3 Restore old delta-RLE bitmap background setting
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.
2023-06-20 22:19:47 +02:00
Vadim Zeitlin
b9fd9c7c8e Merge branch 'about-dialog-compat'
Restore compatibility with the existing code using custom controls in
the "About" dialog.

See #23658.
2023-06-20 22:15:17 +02:00
Vadim Zeitlin
d5ef9d4387 Add wxGenericAboutDialog::GetCustomControlParent()
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.
2023-06-20 19:19:49 +02:00
Vadim Zeitlin
6e0198fffb Make existing code overriding DoAddCustomControls() work again
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.
2023-06-20 18:51:27 +02:00
Vadim Zeitlin
fe66c0e38c Exclude a couple of makefile-like files from whitespace checks
It's require to use TAB for indentation in these files.
2023-06-20 15:12:34 +02:00
Vadim Zeitlin
b93de740c8 Document that wxRB_SINGLE only works in wxMSW
In the other ports it can't be turned off, making it useless.

See #17022, #23652.
2023-06-19 18:58:36 +02:00
Vadim Zeitlin
44da7cb14a Merge branch 'msw-radiobox-tab'
Fix TAB navigation in MSW radio box.

See #23648.
2023-06-19 14:44:07 +02:00
Vadim Zeitlin
a249e21f65 Fix scrollbar creation for Mac windows not using standard peer
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.
2023-06-18 17:41:05 +02:00
Vadim Zeitlin
f42cc5abfe Fix TAB navigation when focus is in wxRadioBox under MSW
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.
2023-06-18 17:02:56 +02:00
Vadim Zeitlin
f99009d693 Simplify wxRadioBox button click handler a little
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.
2023-06-18 16:55:50 +02:00
Vadim Zeitlin
4be9a7568b Create a helper wxRadioBoxButton class
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.
2023-06-18 16:55:50 +02:00
QuentinC
cec057519e Add a few missing and fix a few fuzzy French translations
Closes #23645.
2023-06-17 17:41:27 +02:00
Maarten Bent
d215181c38
Add lexilla to wx-config --libs in static build
Fixes #23643
2023-06-17 15:13:03 +02:00
Maarten Bent
47041389f5
CMake: Don't show warning when webkit2 4.1 cannot be found
It will still show a warning when webkit2 4.00 can also not be found.

See #23633
2023-06-17 15:13:02 +02:00
Vadim Zeitlin
f50fb719e8 Merge branch 'samples-mfc-update' of https://github.com/wsu-cb/wxWidgets
Fix build and behaviour of the MFC sample.

See #23574.
2023-06-16 00:02:43 +02:00
PB
81ce7edb75 Improve documentation about parallel builds with MinGW makefile
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.
2023-06-16 00:01:39 +02:00
Maarten Bent
11ee5b4df5 Only draw selection rectangle for selected items in wxVListBox
Closes #22562.

Closes #23641.
2023-06-15 23:57:41 +02:00
Hartwig Wiesmann
f8af562b20 Avoid spurious clang "undeclared selector" warnings
We check that the selector is really supported before using it, so
suppress the unwanted warnings about doing this.

Closes #23639.
2023-06-15 23:55:51 +02:00
Hartwig Wiesmann
837382510d Avoid using invalid column index in wxOSX wxDataViewCtrl
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.
2023-06-15 23:50:07 +02:00
Vadim Zeitlin
5cef6223c3 Merge branch 'cmake-imported-libs' of https://github.com/MaartenBent/wxWidgets
CMake: Improve finding library name or path of imported targets.

See #23635.
2023-06-15 23:47:44 +02:00
Vadim Zeitlin
d78399dcc9 Merge branch 'webkit2_support_4.1' of https://github.com/swt2c/wxWidgets
Add support for building WebView with libwebkit2gtk-4.1.

See #23633.
2023-06-15 23:42:11 +02:00
Scott Talbert
411e183cd0 Switch Fedora CI to use libwebkit2gtk-4.1 2023-06-13 18:14:04 -04:00
Scott Talbert
1b86644266 Add support for building WebView with libwebkit2gtk-4.1
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.
2023-06-13 18:13:59 -04:00
Maarten Bent
0f1f61a9c8
CMake: Improve finding library name or path of imported targets
Checking LOCATION{_CONFIG} property on interfaces is only supported since CMake 3.19.
Also check the LOCATION and IMPORTED_LIBNAME properties for possible library locations.

Fixes #23632
2023-06-13 21:22:44 +02:00
Maarten Bent
e1f0a938f6
CMake: Fix using Cotire for precompiled headers
Cotire doesn't work when $<COMPILE_LANGUAGE:CXX> is used.
2023-06-13 21:19:44 +02:00
Vadim Zeitlin
d7a98a44ea Fix compilation of wxUILocale with glibc < 2.27
The _NL_WALTMON_xxx constants used since 5b424ea181 (Add wxUILocale
methods for getting month and day names, 2023-05-24) are only available
in glibc 2.27 or later.

See #23191.
2023-06-12 23:06:20 +02:00
Vadim Zeitlin
2b6be286ee Fix using generated wx-config in CMake builds
Since 1c64bd506c (Use grep instead of fgrep and egrep, 2023-05-10) EGREP
wasn't defined in CMake build any longer, so finding the correct config
script always failed.

Fix this by using "grep -E" directly instead of "$EGREP".
2023-06-12 20:46:57 +02:00
Bill Su
7420ab1b26 wxMFCApp::PreTranslateMessage: Give msg to MFC before wxWidgets
because wxWidgets wxGUIEventLoop::PreProcessMessage() seems to
always report that it has consumed msg.

fix #23574
2023-06-11 01:56:21 -04:00
Bill Su
6ab144f9bf samples/mfc: disable composition to allow wxClientDC to work 2023-06-11 01:56:21 -04:00
Bill Su
6b1683757f samples/mfc: building with UNICODE requires wide strings 2023-06-11 01:56:21 -04:00
Bill Su
d970c8eeae samples/mfc: needs #define UNICODE
The header-order workaround for WINVER should also be used for
UNICODE and _UNICODE
2023-06-11 01:56:21 -04:00
Vadim Zeitlin
27aa7e90a7 Merge branch 'gtk-fixes-textctrl' of https://github.com/dsa-t/wxWidgets
Really fix wxTextCtrl size computation in wxGTK and improve
wxTreeTextCtrl positioning in wxTreeCtrl.

See #23001.

Closes #23610.

See #23623.
2023-06-10 17:09:53 +02:00
Richard Powell
6c35c708d5 Fix -Wdeprecated-copy warnings when building in C++20 mode
Avoid implicit copy constructor warnings by using
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY/wxDECLARE_NO_ASSIGN_DEF_COPY
instead of wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN.

Closes #23625.

Closes #23626.
2023-06-10 17:02:13 +02:00
matyalatte
c8fcb0be8f Fix a linker error when wxUSE_PROTOCOL_FILE is off
Fix a linker error for wxProtocolUsewxFileProto when wxUSE_PROTOCOL_FILE
is off but wxUSE_PROTOCOL is on.

Closes #23629.
2023-06-10 17:00:09 +02:00
Alex Shvartzkop
210884ac52 Better positioning for wxTreeTextCtrl. 2023-06-09 18:24:50 +03:00
Alex Shvartzkop
17b72d372f Use calculated margins in wxTextCtrl::DoGetSizeFromTextSize
instead of hardcoded for single-line controls.
2023-06-08 22:04:20 +03:00
Alex Shvartzkop
f9eea9fdfd Gets rid of gtk_entry_get_layout_offsets in GTKGetEntryMargins
due to returning invalid values when used before size_allocate.

Using padding + border on GTK3 and thickness + inner border on GTK2
looks correct.
2023-06-08 21:28:12 +03:00
Vadim Zeitlin
58c49d06fa Minor updates to wxUIActionSimulator documentation
Don't say that it's experimental in configure but do mention that it
doesn't work under Wayland.

Closes #23619.
2023-06-08 01:26:16 +02:00
Tobias Taschner
db09adf6b5 Include macOS 14 name in wxGetOsDescription()
Recognize macOS Sonoma too.

Closes #23615.
2023-06-06 21:20:00 +02:00
Maarten Bent
a801057f1a CMake: Check and enable use of libxkbcommon
CMake's has built-in support for checking xkbcommon using FindX11 since
3.18.

But because older CMake versions are supported, add our own module that
checks if the header and library is available.

See #23410.

Closes #23613.
2023-06-06 21:18:48 +02:00
PB
241ed70b5b Copy all data files needed by XRC sample when building with CMake
XPM files demonstrating the use of wxBitmapBundle in the XRC files
were not copied when building the XRC sample with CMake.

This should have been part of eaa769a (Use wxBitmapBundle in
wxBitmapComboBox XRC handler, 2022-02-09).

Closes #23612.
2023-06-06 21:18:03 +02:00