Commit Graph

69455 Commits

Author SHA1 Message Date
Vadim Zeitlin
859193fb65 Merge branch 'connect-overloaded-c++17'
Make Connect() work with overloaded event handlers in C++17.

See https://github.com/wxWidgets/wxWidgets/pull/2126
2020-12-04 20:02:46 +01:00
Vadim Zeitlin
dc33f27e10 Merge branch 'printf-out-of-mem'
Fix crash in wxString::PrintfV() due to integer overflow/running out of
memory.

See https://github.com/wxWidgets/wxWidgets/pull/2131
2020-12-04 20:01:30 +01:00
Vadim Zeitlin
e98ac38dcb Fix wxStatusBar::SetMinHeight() in wxMSW
This was broken, possibly by 25c9b032a8 (Don't call CacheBestSize() from
DoGetBestSize() implementations, 2016-04-03), as it didn't change the
min size of the status bar and so it was resized to it when it was
managed by wxFrame.

See https://github.com/wxWidgets/wxWidgets/pull/2133

Closes #18996.
2020-12-04 20:00:02 +01:00
Vadim Zeitlin
84e6e5a029 Add another commit to ignore when doing git-blame
This one contains whitespace changes only.
2020-12-04 20:00:00 +01:00
Vadim Zeitlin
a7dfedf602 Skip URL test if it fails when running on AppVeyor
Failing it is not useful, this results in the CI failure when in 99% of
the cases the transient network problem which resulted in this test
failure has nothing to do with the changes being tested.
2020-12-04 19:29:59 +01:00
Paul Cornett
24a982e6e2 Fix wxGraphicsContext size with Cairo when created from wxImage. See #18995 2020-12-01 19:32:53 -08:00
Vadim Zeitlin
344cc940a0 Impose upper limit on memory allocation in wxString::PrintfV()
Don't loop indefinitely until we run out of memory, possibly after
wrapping around INT_MAX, but impose an arbitrary limit of 128MiB for the
max allocation done by wxString::PrintfV() when the provided format
string or one of the arguments are invalid.

This notably fixes a crash when trying to use "%c" to output an invalid
Unicode character.

Also improve comment explaining DoStringPrintfV() logic and change the
size type to size_t from int.

Co-Authored-By: Arrigo Marchiori <ardovm@yahoo.it>
2020-12-01 21:53:55 +01:00
Vadim Zeitlin
8fb4ab99f1 Always return -1 but set errno in our wxVsnprintf() on error
This makes it more compatible with the standard behaviour of vswprintf()
and allows to use the same logic in the builds using our version of this
function and the normal ones in DoStringPrintfV(), simplifying its
(already rather hairy) logic.

Update the tests to not require any particular return value in case of
buffer overflow, as this differs between Unicode and non-Unicode builds.
When we finally drop the latter, we should just check that it always
returns -1 in this case.

Note that ideal would be to return the actually needed size of the
buffer in case of the error due to buffer being too small, but this
isn't that simple to do and it's probably not worth spending time on
improving this code as long as we still need to use the buffer doubling
strategy in DoStringPrintfV() when using the standard vswprintf().
2020-12-01 21:53:55 +01:00
Marcos
cda21c8ddc Fix a cosmetic bug in ExtendRulesAndAlternateColour() code
Ensure that vertical rules extend to the bottom of the window on the
non-first page of the control too.

This was probably broken in 5ae2a8ebb8 (Simplify API for extending
wxListCtrl background display, 2020-11-09).

Closes https://github.com/wxWidgets/wxWidgets/pull/2130
2020-12-01 01:32:26 +01:00
Vadim Zeitlin
7a2786bf11 Get rid of CppUnit macros in wxVsnprintf() tests too
Use CATCH macros directly.

Also remove some unnecessary casts and wxT().
2020-12-01 00:53:07 +01:00
Vadim Zeitlin
388dfb9fad Replace various CMPn() macros with a single CMP() vararg one
Reduce duplication and simplify the test code by using the same macro
for any number of printf() arguments.

Note that this relies on "##__VA_ARGS__" gcc extension to work even for
CMP0(), i.e. when there are no parameters at all. If this ever becomes a
problem, we can always reintroduce a separate CMP_NO_ARGS() macro.
2020-12-01 00:51:35 +01:00
Stefan Csomor
fab9a67d23 Guard against NULL Sockets
I’ve not been able to reproduce it always, but when using wxHTTP the internal socket was sometimes already closed. So just guard against crashes.
2020-11-30 18:49:38 +01:00
Vadim Zeitlin
db9727ac26 Remove CppUnit test case boilerplate from wxVsnprintf() unit test
Use separate CATCH test cases for different tests.

No real changes, just update and simplify.
2020-11-30 17:17:20 +01:00
Vadim Zeitlin
f4db86cc77 Fix signed/unsigned comparison warnings in wxVsnprintf test
These warnings only appeared in build configurations using our own
implementation, i.e. not in the default build.
2020-11-30 17:10:05 +01:00
Stefan Csomor
14fb1c5fe1 wrapping private types properly in UTI 2020-11-29 20:42:26 +01:00
Maarten Bent
bdc18f68b6 Update wxHtmlWindow on DPI change
This is not ideal, as resetting the page contents loses the current
selection and redoes a lot of work that could be avoided, but it's
(much) better than nothing, as it fixes the window appearance after e.g.
moving it to another monitor.

Closes #18564.
2020-11-28 16:56:22 +01:00
Maarten Bent
39ca664053 Improve handling of non default DPI in wxHtmlWindow deawing code
This replaces the fix of f4dcac9f44 (Return wxFont adjusted to DPI in
wxHtmlWinParser::CreateCurrentFont(), 2020-11-25) adjusting the font
explicitly under MSW with a better fix, associating the correct window
(and hence DPI) with the device context used in OnPaint().

See #18564.
2020-11-28 16:56:10 +01:00
Vadim Zeitlin
ef9161861d Fix invalid memory read in wxMSW wxTextCtrl::GetLineText()
Don't read before the start of the buffer when getting the text of an
empty line, this was (correctly) flagged as heap error by address
sanitizer.
2020-11-28 16:35:03 +01:00
Vadim Zeitlin
7dbcbad7c6 Merge branch 'misc-dpi-bugs' of https://github.com/MaartenBent/wxWidgets
Miscellaneous DPI-related bug fixes.

See https://github.com/wxWidgets/wxWidgets/pull/2128
2020-11-27 15:14:06 +01:00
Maarten Bent
f4221b6df5 Improve GetSizeFromText in wxComboCtrl
Also take default text indent into account, and use the actual button area width.

Closes #18930.
2020-11-26 20:52:49 +01:00
Maarten Bent
f4dcac9f44 Return wxFont adjusted to DPI in wxHtmlWinParser::CreateCurrentFont()
See #18564.
2020-11-26 20:52:49 +01:00
Maarten Bent
78decce3d8 Don't change sizer dimensions on DPI change
Closes #18969.
2020-11-25 23:52:32 +01:00
Paul Cornett
32c8b4dc8c Fix wxRibbonToolBar layout
Broken by 1e753f97ba (Remove initializations which are the default value, 2019-02-25)
See #18985
2020-11-24 08:47:42 -08:00
Joao Matos
feebe8e763 Fix handling of GTK cursor events to set window event object and id. 2020-11-23 22:47:15 -08:00
Vadim Zeitlin
433480f7d0 Merge branch 'bitness' of https://github.com/lanurmi/wxWidgets
Replace "architecture" with "bitness" for the value indicating whether
the architecture uses 32 or 64 bits.

See https://github.com/wxWidgets/wxWidgets/pull/2122
2020-11-22 00:35:29 +01:00
Vadim Zeitlin
f48099e00a Make Connect() work with overloaded event handlers in C++17
This used to work previously but got broken when using C++17 by
c3810da549 (Allow using noexcept methods with event tables macros,
2020-04-09), as cast added to deal with noexcept handlers relied on
argument type deduction which can't be done for overloaded functions.

Fix this by extracting the event argument type from the function pointer
type and specifying it explicitly, while still letting the compiler
deduce the class.

Add a test case checking that using overloaded event handlers compiles.

See #18721.

Closes #18896.
2020-11-21 20:52:13 +01:00
Lauri Nurmi
b74702543b Rename wxPlatformInfo::*Arch* to *Bitness*, deprecate old names 2020-11-21 19:16:21 +02:00
Bill Su
47078992c6 Fix handling of mask in wxBitmap::ConvertToImage()
Handling mask when converting wxBitmap to wxImage was accidentally
broken by 7e9afad53a (Add real support for monochrome bitmaps to wxMSW,
2020-10-19). Fix this now and reuse the new wxMonoPixelData to make the
code simpler and more readable.

This commit is best viewed ignoring whitespace-only changes, as it
unindents a large block of code.

Closes https://github.com/wxWidgets/wxWidgets/pull/2125

Closes #18974, #18975.
2020-11-21 18:14:02 +01:00
Lauri Nurmi
68ea3c59f1 Explain in wxPlatformInfo docs that it means bitness when it says architecture
In the context of wxPlatformInfo, 'architecture' means either '32 bit' or
'64 bit'. Anywhere outside the context of wxPlatformInfo, this concept is
known as 'bitness'.

For the rest of the world, 'architecture' generally refers to the CPU
instruction set architecture, i.e. something like x86, x86_64, arm64, whereas
'operating system architecture' refers to the design of separating kernel
space, user space, etc.
2020-11-21 18:17:18 +02:00
Paul Cornett
b27aefacef Fix wxSplitterWindow sash appearance with some GTK themes
See #18981
2020-11-21 08:09:23 -08:00
Paul Cornett
dd864cffe0 Fix border drawing glitch in wxGrid column header
See #18980
2020-11-20 21:46:09 -08:00
Vadim Zeitlin
1afd2248d7 Enable C++11-only Bind() unit test for MSVS 2015+ too
This might compile with even earlier MSVS versions, but it definitely
does with the recent ones, so enable the test for this compiler, even if
it still doesn't define __cplusplus to indicate C++11 conformance by
default.
2020-11-20 01:50:35 +01:00
Vadim Zeitlin
5c7da1b357 Get rid of CppUnit boiler plate in wxEvtHandler unit test
No changes, just remove the useless test case class and use individual
test cases instead of its methods.
2020-11-20 01:50:35 +01:00
Lauri Nurmi
493cc3571e Add wxGetCpuArchitectureName() for finding out CPU architecture
The returned value is OS-dependent and can be something
like: "x86_64", "x86", "arm64".

Closes https://github.com/wxWidgets/wxWidgets/pull/2121
2020-11-19 23:32:34 +01:00
Vadim Zeitlin
4bd0cd40f4 Merge branch 'persistent-combobox'
Add wxPersistentComboBox class and fix persistent classes compilation
when wxString implicit conversions are disabled.

See https://github.com/wxWidgets/wxWidgets/pull/2123
2020-11-19 23:30:51 +01:00
Vadim Zeitlin
4b375971b1 Add version information to wxPersistentComboBox documentation
Just add the previously forgotten "@since" tag.
2020-11-19 23:30:13 +01:00
Vadim Zeitlin
152ec51033 Add missing wxUSE_XXX checks to persistent adapters headers
Make sure these headers can be compiled even when the control they're
written for is not available in the build. Including them in this case
doesn't make much sense, of course, but not giving any errors is still
nicer and consistent with the rest of wx headers.
2020-11-19 16:34:17 +01:00
Vadim Zeitlin
a1d43c9363 Make wxRound() compile for all integer types again
Replace the overloads added in c2e5f3520a (Add a wxRound() overload for
int, 2020-11-05) and 1cf7c47934 (Add more wxRound() compatibility
overloads and improve docs, 2020-11-05) with a template function that
should work for all integer types.

This fixes compilation of existing code using wxRound() with size_t
values: while this doesn't make any sense, it doesn't make much less
sense than using it with int, so let people avoid having to change their
code when upgrading to wx 3.2.

Also add at least some minimal tests for this function.

Closes https://github.com/wxWidgets/wxWidgets/pull/2119
2020-11-19 15:45:22 +01:00
Vadim Zeitlin
712c2d4004 Add possibility to create "Close" bitmap button from XRC
This requires refactoring NewCloseButton() in order to extract
CreateCloseButton() from it, as XRC relies on being able to use two-step
creation which was previously impossible for this kind of buttons.

CreateCloseButton() is rather unusual, as it has to be declared in the
derived, platform-specific class, in order to be able to call its
Create(), but is defined only once in common, platform-independent,
code. However the only alternative seems to be to have a static
function, e.g. InitCloseButton(), which wouldn't be very pretty neither.

Closes https://github.com/wxWidgets/wxWidgets/pull/2118
2020-11-19 15:44:54 +01:00
Vadim Zeitlin
b4338a30e1 Fix IsEnabled() return value for wxMSW TLWs with native dialogs
IsEnabled() wrongly returned true even when the TLW was actually
disabled due to a native modal dialog using it as owner being currently
shown.

Fix this by trusting the actual HWND state, rather than our internal
m_isEnabled, except before the window is created.

Do it for TLWs only even if, in principle, we could check for
WS_DISABLED for the other windows too. However this would make
IsThisEnabled() inconsistent with the other platforms, where it returns
true when the window parent is disabled, but the window itself isn't,
which is currently also emulated by wxMSW, but wouldn't be the case if
we trusted WS_DISABLED presence. And while there might be other problems
due to lying about the actual window state in this function, it doesn't
seem to create any problems in practice, so for now leave the old logic
in place.

As a side effect, this makes wxWindowDisabler work correctly when a
message box is shown by another window when it's created, as it will now
correctly avoid re-enabling the message box parent in its dtor.

Closes https://github.com/wxWidgets/wxWidgets/pull/2117

See #11887.
2020-11-19 15:44:54 +01:00
Vadim Zeitlin
b92d194ac4 Add "default" and "bitmap" to wxCommandLinkButton XRC handler
Support the same buttons as in wxButton, as they also make sense here.

Closes https://github.com/wxWidgets/wxWidgets/pull/2116
2020-11-19 15:43:01 +01:00
Vadim Zeitlin
7f5d45b9b4 Add wxPersistentComboBox for saving and restoring combobox items
This allows to preserve the history of user input.
2020-11-19 13:06:37 +01:00
Vadim Zeitlin
8469642959 Include persistent controls headers in the all headers test
Check for the absence of warnings when compiling these headers too, they
were simply forgotten (and not intentionally excluded) before.
2020-11-19 13:06:37 +01:00
Vadim Zeitlin
b63cf77dd3 Fix persistent classes build without implicit wxString encoding
Ensure that all headers in wx/persist can be compiled with
wxNO_IMPLICIT_WXSTRING_ENCODING defined.
2020-11-19 13:06:37 +01:00
Vadim Zeitlin
d67c7c485a Fix wxWindowDisabler compilation in wxOSX
Remove the duplicated version of the code in wxOSX sources which wasn't
updated in the parent commit.
2020-11-17 00:49:32 +01:00
Vadim Zeitlin
be570015bf Replace wxList with wxVector in wxWindowDisabler implementation
No real changes, just get rid of an unnecessary instance of
wxWindowList: this one can be safely replaced with a vector because it's
a private member and so changing its type doesn't affect compatibility.
2020-11-16 16:48:47 +01:00
Vadim Zeitlin
516066939a Add trivial wxVectorContains() helper
This is nicer than using std::find() when only a test for presence is
required.
2020-11-16 16:48:47 +01:00
Vadim Zeitlin
b021c3c938 Remove useless asserts from wxWeakRef implementation
No real changes, just remove asserts verifying that a pointer is
non-null right before dereferencing it, as they're perfectly useless for
all the usual reasons and just add extra code to relatively often used
functions.
2020-11-16 01:50:27 +01:00
Vadim Zeitlin
84409dfa0a Don't send wxEVT_ACTIVATE to half-destroyed windows in wxMSW
This resulted in a crash when WM_ACTIVATE was received from inside
wxWindow dtor, executed after wxTopLevelWindowMSW dtor, and passed to a
handler defined in wxTopLevelWindowMSW and using its already destroyed
members.

Perhaps we should avoid dispatching any messages when the window is
being destroyed, but it's not totally obvious that this is not going to
break something, so for now apply just this minimal fix.

Closes #18970.
2020-11-16 01:47:59 +01:00
Vadim Zeitlin
bd05aea6c1 Fix stretchable separators in vertical toolbars under MSW
This partially reverts 44d732b8a5 (Use TB_SETBUTTONINFO when updating
stretchable toolbar separators, 2019-02-24) and restores the behaviour
before this commit for the vertical toolbars only, as the new code
doesn't work for them, even though like it seems it should (and we don't
get any error when using it).

Still keep the simpler path for horizontal toolbars, as there doesn't
seem to be any problems with it in this case.
2020-11-15 01:02:09 +01:00