Handle executable DefaultIcon values such as %1/%L by asking the
shell for an icon location and falling back to the stock application
icon when SHGetFileInfo() does not provide a file/index location.
Add a base test covering the .exe icon location path.
Fixes#21794.
Closes#26673.
A command ending in a bare '%' made the loop advance in this function
advance past the end of string.
Fix this by handling only non-trailing '%' specifically
Closes#26531.
Previously comparing objects of this type involved implicitly converting
both of them to the unspecified_bool_type and then comparing these
values, which meant that all non-null pointers were considered to be
equal.
Fix this now and add a trivial unit test which was failing before this
commit.
Move determining compile-time GTK+/QT versions to wxAppTraits,
which is presumably the only reason why wxGetLibraryVersionInfo()
needed to be in core.
Revert "Move wxGetLibraryVersionInfo() to core from base."
This reverts commit 9aea251043.
Closes#25236.
By defining WX_TEST_TEXT_WRAP and WX_TEST_TEXT_WIDTH it's possible to
see how the given text would be wrapped at the given width, which is
useful for testing.
Don't move words to the next line if they just fit into the current one.
This requires checking for the space just at the boundary before looking
for the previous or next space and also using the correct predicate with
lower_bound() which uses inexact comparison.
The existing code behaved completely wrongly whenever a word longer than
the maximal width was present as it just gave up and didn't wrap
anything at all after it -- when it should have just let this word
overflow but still wrap the rest.
Fix this and add a unit test checking that this works correctly now
(several of the tests would have failed before).
Closes#23339.
This could be enhanced, e.g. break lines at characters other than
spaces, support Unicode better etc, but for now add just a very simple
function that should be suitable for wrapping help message in
wxCmdLineParser, where it will be used next.
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.
alpha and ia64 use libc.so.6.1, GNU/kFreeBSD uses libc.so.0.1, and
GNU/Hurd uses libc.so.0.3, so check for these versions too in addition
to 6 and 7 used under x86 Linux.
Closes#23801.
While running the test_base on CYGWIN, this message will be printed on the console:
-------------------------------------------------------------------------------
DynamicLibrary::Load
-------------------------------------------------------------------------------
/cygdrive/c/Users/carlo/Documents/GitHub/wxWidgets/tests/misc/dynamiclib.cpp:26
...............................................................................
/cygdrive/c/Users/carlo/Documents/GitHub/wxWidgets/tests/misc/dynamiclib.cpp:80: warning:
Couldn't find libc.so, skipping DynamicLibrary::Load() test.
/cygdrive/c/Users/carlo/Documents/GitHub/wxWidgets/tests/misc/dynamiclib.cpp:84: warning:
Possible candidates:
/lib/libc.a
/usr/lib/libc.a
CYGWIN uses NEWLIB as C library and it is compiled into cygwin1.dll.
This patch adds the right test case for CYGWIN, for letting the execution of the test.
Closes#23781.
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>
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.
Fix a long-standing bug in wxMSW wxTextDataObject which returned the
size including the trailing NUL from its GetDataSize() and used the same
convention in GetData(), but didn't account for this NUL being included
into the buffer passed to SetData().
This was partially compensated by also passing the wrong (too small)
buffer size when calling SetData() from wxIDataObject, but still
resulted in problems when using SetData() with the length returned from
GetDataSize(), as done in wxDataViewCtrl code.
Fix this by now always considering NUL part of the buffer (as this is
the platform convention, i.e. all CF_TEXT data on the system clipboard
must include the trailing NUL) and taking it into account when
determining the buffer size in wxIDataObject.
This change is not fully backwards-compatible as it breaks any code
calling SetData() directly, as e.g. wxURLDataObject in wxMSW itself did,
so document it as such, but it's still worth making it as there doesn't
seem to be any other way of fixing the problem described in the linked
issue and direct calls to SetData() should be rare as simpler SetText()
should be used instead.
Also add a unit test for wxTextDataObject and extend the existing test
of wxURLDataObject.
Closes#22928.
Stop using vararg macros in wxFileTypeInfo and make ctor a template
function instead, this is simpler and more clear.
Add a unit test checking that the ctor still behaves as expected.
This is a combination of running clang-tidy with modernize-use-nullptr
check for some ports (GTK, X11, OSX) and manual changes to the ports for
which it couldn't be used easily (MSW, DFB) and also manually updating
the docs.
Also replace NULL with null or nullptr in the comments as this is more
consistent with the use of nullptr in the code and makes it simpler to
grep for the remaining occurrences of NULL itself.
And also use null in the assert messages.
Only a few occurrences of "NULL" are still left in non-C files, mostly
corresponding to unclear comments or string output which it might not be
safe to change.
Don't hard code the path to it, even different Linux versions use
different paths, e.g. /lib/x86_64-linux-gnu under Debian and /lib64
under Fedora, so just try all the possibilities until we find something.
Don't use operator<<() with a wide char string, as this overload has
been removed in C++20. This can be done simply by not using wide char
string at all in this test, as it's not really needed.
Co-Authored-By: Vadim Zeitlin <vadim@wxwidgets.org>
Closes#22599.
This doesn't work under FreeBSD, even if the file exists there.
Show the existing libc candidates on such systems to see if any of them
look plausible.
Use existing path for libc.so on Linux/x86_64 platforms to prevent the
test from just exiting without doing anything.
Also don't give a compilation error for unknown platforms, just a
run-time warning is sufficient.
The changes of 2144ca38d2 (Get rid of CppUnit boilerplate in
DynamicLibraryTestCase, 2022-04-17) accidentally undid the workaround
from 054cb35b39 (Workaround for a crash with gcc 9.1 from MSYS2 MinGW
32bit, 2019-08-03), so work around the same problem again by avoiding
using CHECK() with function pointers.
Use CATCH macros directly, this is simpler and more clear.
Also use narrow strings instead of wide ones and get rid of wxT() too.
No real changes.
This commit is best viewed ignoring whitespace-only changes.
Under Monterrey (macOS 10.12) we can actually load the file using
wxDynamicLibrary even though it does _not_ exist on the disk, so don't
skip the test just because of this.
Define wxDataFormat::operator==(wxDataFormatId) instead of relying on
the implicit conversion from wxDataFormatId to wxDataFormat, as this
can't be done when the format ID is wxDF_INVALID because creating
wxDataFormat results in an assert failure in this case, while comparing
with wxDF_INVALID is clearly a perfectly valid operation.
Add a unit test checking for this.
Closes#22213.
This function was defined in wxGTK and wxOSX, but not in wxMSW or the
other ports, but it can be useful there too, so make it public and
define it in common code.
Define various macros used in the test code (or in the headers included
from it) as nothing when wxDEBUG_LEVEL==0.
Also don't define a helper function used when asserts are enabled in
this build to avoid clang warnings about unused function.
This undoes accidental change of ms_classInfo from public to protected
in 95c98a0b5f (Work around -Wuggest-override for event table macros from
gcc 11, 2021-04-25).
Also add a unit test checking that using wxCLASSINFO(wxObject) compiles
and works as expected.
This internal function will be useful to check if the modules are
already initialized, i.e. if the library is in the "steady state"
between the end of the initialization and the beginning of the cleanup
phases.