Commit graph

3084 commits

Author SHA1 Message Date
Vadim Zeitlin
c2e5749443 Fix crash when reading truncated GIF image
Add a unit test case checking that we don't crash any longer and still
read the image meta data correctly, even if not the image itself.

Also add another check for EOF and possibly invalid "bits" value in
another place where we were not checking for it when reading from the
stream.

Closes #23409.

Co-authored-by: PB <PBfordev@gmail.com>
2023-07-02 18:06:03 +01:00
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
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
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
Brian Nixon
381c39a051 Clear grid attribute cache when loading new table
Clear the cached attributes when replacing the table they were used
with.

Add unit test checking that the attributes are not used any longer.

Closes #23607.
2023-06-05 15:22:49 +02:00
Brian Nixon
b9d0541f9a Make wxSocket::Peek() work with UDP too
Fix wxSocketImpl::RecvDgram() when caller requests fewer bytes than
are present in datagram, as we must always read all the available bytes
when using UDP -- they are not buffered by the OS and so won't be
provided by the next Read() call.

Closes #23594.

Closes #23604.
2023-06-05 01:49:41 +02:00
Brian Nixon
b473163da2 Correct delta-RLE bitmap background colour
Use black instead of the first palette colour for the implicit
background for RLE bitmaps for consistency with Windows itself.

Closes #23599.
2023-06-04 00:38:39 +02:00
Brian Nixon
d78e9fb1cb Correct loading of BI_BITFIELDS bitmaps
This fixes several minor bugs in the loading of `BI_BITFIELDS` bitmaps,
related to handling different header sizes and the colour and alpha
masks.

Closes #23601.
2023-06-03 21:07:40 +02:00
Vadim Zeitlin
a3e925df0a Merge branch 'mac-uilocale-script-fix'
Locale-related fixes for macOS and new calendar names localization
functions.

Closes #23209.

See #23556.
2023-06-03 21:07:40 +02:00
Brian Nixon
28d6234bfe Add image test to compare BMP creation methods
Check that loading BMP files directly using wxDIB and via wxImage
built-in support for them produces the same result (which wasn't the
case for the RLE-compressed bitmaps until the last commit).
2023-05-31 21:19:14 +01:00
Vadim Zeitlin
d2101ca3be Show result of parsing wxLocaleIdent in wxUILocale pseudo test
In addition to showing whether the locale is supported or not, show all
of its components to allow interactively verifying if an identifier is
being parsed correctly.
2023-05-19 01:33:13 +02:00
Vadim Zeitlin
92664881fe Fix lack of unsharing in wxImage::Clear()
Calling Clear() wrongly modified any other wxImage objects reusing the
same data.

Fix this by adding the missing call to AllocExclusive() to this function
and also add a check for the image validity which was missing there as
well ever since this function was added back in fc3762b5fc (add
wxImage::Clear (patch by troelsk); closes #10141, 2009-01-09).

Also add a unit test.

Closes #23553.
2023-05-18 00:31:15 +02:00
Vadim Zeitlin
d56d773a55 Remove CppUnit boilerplate in wxImage unit test
No real changes, just remove all the ugly compatibility macros.
2023-05-18 00:25:35 +02:00
Vadim Zeitlin
4a2d256e94 Remove CppUnit boilerplate from wxURL unit tests
No real changes, just don't use compatibility macros any longer.

Also remove URLTestCase as it's useless now when we can just use
wxSocketInitializer directly.
2023-05-18 00:10:28 +02:00
Vadim Zeitlin
1afcac9ca5 Use wxSocketInitializer in the unit tests
Prefer using this RAII wrapper to explicit function calls, this is
shorter and more robust.
2023-05-18 00:06:21 +02:00
Vadim Zeitlin
c41969eff2 Disable wxHyperlinkCtrl colours test under Wine
This doesn't work due to LM_GETITEM not returning the expected result
after changing the state using LM_SETITEM under Wine.

It could be worked around by remembering whether we changed the colours
in our own variable, or maybe just reverted later if Wine fixes this,
but for now disable the test.
2023-05-15 21:50:31 +01:00
Vadim Zeitlin
cd28031b4d Document that wxMSW wxHyperlinkCtrl hover colour can't be changed
This isn't supported by the native control, and it doesn't seem worth to
make an extra effort to support it, so just document it and stop
checking that it works in the unit test.
2023-05-15 21:39:13 +01:00
Vadim Zeitlin
5b9b817aaa Simplify showing colour values in failing unit tests
Use wxColour::GetAsString() instead of reimplementing it in the test.
2023-05-15 21:39:13 +01:00
Vadim Zeitlin
02eb3a26b6 Fix using colours, fonts etc in CATCH assert messages
Include the header declaring the stream insertion operators for these
types before including catch.hpp itself as otherwise they may not be
seen when these classes are used and Catch::StringMaker is instantiated
using the "unstreamable" alternative for them.

It would probably be better to specialize Catch::StringMaker for these
types directly instead of relying on stream insertion operators, but
this would require more changes and in the meanwhile this improves the
display of failing checks.
2023-05-15 21:39:13 +01:00
Vadim Zeitlin
d1fedc1415 Get rid of CppUnit boilerplate in wxHyperlinkCtrl unit test
No real changes, just avoid using compatibility macros in this test.
2023-05-15 21:39:13 +01:00
Vadim Zeitlin
5f5e5c27dd Merge branch 'keep-on-same-display'
Keep window on the same display when its client size is changed.

See #23533.
2023-05-10 22:45:02 +01:00
Vadim Zeitlin
54a8a6ac16 Fix wxTreeCtrl::ScrollTo() with hidden root item in wxMSW
Scroll to the topmost item, as the generic version does, instead of
crashing.

Closes #23534.
2023-05-10 19:08:00 +01:00
Vadim Zeitlin
5fd6be2f64 Add wxRect::MakeCenteredIn() modifying the rectangle in place
This can be more convenient than calling CenterIn().
2023-05-10 00:09:41 +01:00
Vadim Zeitlin
1a22adb80d Get rid of CppUnit boilerplate in wxRect unit test
No real changes, just clean up the test.
2023-05-10 00:02:58 +01:00
Vadim Zeitlin
d39aac0fa8 Merge branch 'aui-tbar-items'
Fix regression in code using pointers to wxAuiToolBar elements.

See #23529.
2023-05-08 15:15:02 +01:00
Vadim Zeitlin
4d48e47811 Fix regression in destroying wxArtProvider objects
Don't delete the art provider object in Remove() as this contradicted
its contract and do restore the call to Remove() from wxArtProvider dtor
as it's actually documented to work.

This fixes a regression due to the changes of 4a294caacd (Stop using
macro-based wxList in wxArtProvider code, 2023-04-11).

Closes #23513.

Closes #23529.
2023-05-08 15:13:35 +01:00
Vadim Zeitlin
50dcf06bff Revert to using wxBaseObjectArray for wxAuiToolBarItemArray
This partially undoes the changes of bc23b1f4f0 (Use wxBaseArray instead
of object array for wxAuiToolBarItemArray, 2023-04-11) as they broke the
existing code using wxAuiToolBar because the pointers to the tools were
not stable any more.

At least avoid the use of the ugly -WX_DECLARE_USER_EXPORTED_OBJARRAY()
macro by just using wxBaseObjectArray<> directly, which is simpler now,
after the change in the parent commit.

Add a trivial test checking that pointers to wxAuiToolBar tools remain
stable when more tools are added.

Closes #23514.
2023-05-07 00:52:07 +01:00
Vadim Zeitlin
4df2c878f4 Add wxSTC project to the GUI tests MSVS solution
The tests depend on wxSTC library, so add the project to ensure that it
is (re)built when building them.
2023-05-06 19:43:00 +01:00
Vadim Zeitlin
a2e3dd563e Check that we retrieve the same numbers of files in wxFTP test
GetFilesList() and GetDirList() should return the same number of lines,
normally, so check for this.
2023-05-04 17:06:02 +01:00
Vadim Zeitlin
5e3c2fb1c6 Don't use raw pointers in wxFTP unit test
Use std::unique_ptr<> and vector<> instead.
2023-05-04 16:38:29 +01:00
Vadim Zeitlin
649c64bab1 Replace CPPUNIT_ASSERT with CATCH macros in wxFTP unit test
No real changes, just stop using legacy macros.
2023-05-04 16:36:28 +01:00
Vadim Zeitlin
8d8f94da64 Merge branch 'webkit2_fixes' of https://github.com/swt2c/wxWidgets
Miscellaneous fixes for WebKit2 wxWebView backend.

See #23497.
2023-04-28 16:39:49 +02:00
Vadim Zeitlin
5d2639d1cf Merge branch 'std-iostream-fixes'
Restore wxDocument::{Save,Load}Object() compatibility with the old
non-STL build.

See #23481.
2023-04-28 15:26:54 +02:00
Vadim Zeitlin
fd0a52250d Remove redundant wxUSE_STD_IOSTREAM test
It's not necessary to check for it as wxHAS_TEXT_WINDOW_STREAM is only
set to 1 if standard streams are used.
2023-04-28 15:26:46 +02:00
Vadim Zeitlin
85e88d6af3 Merge branch 'format-unicode-fix' of https://github.com/lanurmi/wxWidgets
Fix for wxLocale breaking Unicode string formatting under macOS.

See #23454.
2023-04-28 15:06:54 +02:00
Scott Talbert
9688ccc087 WebView tests: Fix Selection test with WebKit 2.40+
For some reason, calling HasSelection() immediately after SelectAll()
causes the web extension to get stuck under WebKit 2.40.  Instead of
sleeping, call wxYield() a few times to let the event loop run a bit.
2023-04-26 10:26:16 -04:00
Vadim Zeitlin
7465d8297e Add wxString::wc_string() for consistency
We have utf8_str() and utf8_string(), but no similar equivalent for
wc_str(), so add one too, it seems nicer to use than ToStdWstring().

Closes #23463.
2023-04-20 15:20:13 +02:00
Vadim Zeitlin
8e35b647c3 Use std::unordered_map<> in private wxWebRequest headers
Replace wx synonym with the direct use of the standard class.
2023-04-18 00:42:56 +01:00
Vadim Zeitlin
080b59ca8b Use std::unordered_map<> in the GUI unit test code
This allows to use the correct types for the map keys and values too.
2023-04-18 00:42:55 +01:00
Vadim Zeitlin
7824391f64 Merge branch 'use-std-containers'
Remove avoidable uses of legacy container classes by replacing them with
the standard containers.

See #23440.
2023-04-17 17:02:27 +02:00
Lauri Nurmi
aefd1e41c7 Attempt to test whether wxLocale breaks formatting Unicode strings 2023-04-17 02:04:59 +03:00
Vadim Zeitlin
889845fbc4 Add support for wxNO_IMPLICIT_WXSTRING_CONV_TO_PTR to wxString
This symbol is similar to the existing wxNO_IMPLICIT_WXSTRING_ENCODING
and can be defined when building the application (as opposed to when
building the library) to disable implicit wxString conversions to
pointer types, i.e. char*, wchat_t* and void*.

This makes the just added wxUSE_CHAR_CONV_IN_WXSTRING library build
option unnecessary, so remove it.
2023-04-16 01:16:56 +02:00
Vadim Zeitlin
4913857ef7 Define wxNO_UNSAFE_WXSTRING_CONV if wxUSE_UNSAFE_WXSTRING_CONV==0
This doesn't really change anything, but allows to simplify the tests,
as we can now check only for wxNO_UNSAFE_WXSTRING_CONV and this covers
both the case of the library compiled without support for the unsafe
conversions at all and the case when the conversions are disabled by
explicitly defining wxNO_UNSAFE_WXSTRING_CONV when building the
application.
2023-04-16 01:16:56 +02:00
Vadim Zeitlin
35c35c235e Remove wxUSE_STL which is not really used any longer
wxString is always based on std::[w]string since 2c0c727f49 (Remove wx
own wxStringImpl implementation, 2022-11-16) and all containers use
standard containers by default too now -- and there is a separate
wxUSE_STD_CONTAINERS for this anyhow.

The only remaining use of wxUSE_STL was as the default value for
wxUSE_STD_STRING_CONV_IN_WXSTRING option, but it's not really needed
for this neither, and this option can just be set to 0 by default.

Also add wxUSE_CHAR_CONV_IN_WXSTRING which can now be set to 0 too to
disable all unwanted implicit conversions (even "safe" ones, to wide
strings, in addition to the unsafe ones to narrow strings that could be
already disabled with wxUSE_UNSAFE_WXSTRING_CONV) to allow people who
don't want to have any implicit conversions at all to do it.

Keep --enable-stl configure option for compatibility, but warn if it is
used to tell people that it is not needed any longer.
2023-04-15 17:22:09 +02:00
Vadim Zeitlin
d65eed50fa Replace some occurrences of wxUSE_STL with wxUSE_STD_CONTAINERS
The latter option will remain, while the former one won't be used at all
any longer soon, so prefer using the latter whenever possible.
2023-04-15 15:14:41 +01:00
Vadim Zeitlin
338751756f Use std::vector<wxImage> instead of wxImageArray
Preserve the old dynamic array name but just define it as a thin class
deriving from std::vector and accept just vector in SaveAnimation().
2023-04-12 18:09:47 +01:00
Vadim Zeitlin
8fd4f5e79d Merge branch 'to-from-chars' into drop-x-fonts
Use C++17 std::{to,from}_chars() for conversions between wxString and
numbers in C locale.

See #23422.
2023-04-12 16:42:03 +02:00
Vadim Zeitlin
15936efed9 Merge branch 'use-stl-tweaks'
Minor changes related to wxUSE_STL.

See #23435.
2023-04-10 16:21:36 +02:00
Vadim Zeitlin
6ea0589ed3 Remove unnecessary wxUSE_STL test from HTML parser benchmark
The same code can be used in STL and non-STL builds.
2023-04-09 02:33:22 +02:00
Vadim Zeitlin
e9527ee5a2 Define wxArchiveIterator in all builds, not just STL one
Doing this doesn't introduce any backwards compatibility problems, so do
it always, and not only when wxUSE_STL==1.
2023-04-09 02:33:22 +02:00