wxWidgets/tests/misc
Vadim Zeitlin 2892794d70 Consistently include trailing NUL in wxMSW wxTextDataObject size
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.

This commit is a modified version of the master one as it still accepts
non-NUL terminated strings too, for compatibility, so it shouldn't break
any existing code.

See #22928, #23018.

(cherry picked from commit d737d98d278a43ef4b16a756f3115bbf65962358)
2022-12-27 23:37:55 +01:00
..
dynamiclib.cpp Determine location of libc dynamically in wxDynamicLibrary test 2022-08-14 18:19:01 +02:00
environ.cpp Remove BCC-specific hdrstop pragma from everywhere 2020-10-12 21:58:37 +02:00
garbage.cpp Remove BCC-specific hdrstop pragma from everywhere 2020-10-12 21:58:37 +02:00
guifuncs.cpp Consistently include trailing NUL in wxMSW wxTextDataObject size 2022-12-27 23:37:55 +01:00
metatest.cpp Remove BCC-specific hdrstop pragma from everywhere 2020-10-12 21:58:37 +02:00
misctests.cpp Fix tests build with wxDEBUG_LEVEL==0 2021-08-21 15:05:13 +02:00
module.cpp Add wxModule::AreInitialized() 2021-03-07 20:39:09 +01:00
pathlist.cpp Remove BCC-specific hdrstop pragma from everywhere 2020-10-12 21:58:37 +02:00
safearrayconverttest.cpp Remove BCC-specific hdrstop pragma from everywhere 2020-10-12 21:58:37 +02:00
selstoretest.cpp Add a unit test exercising the bug fix in the parent commit 2021-01-23 16:40:30 +01:00
settings.cpp Remove BCC-specific hdrstop pragma from everywhere 2020-10-12 21:58:37 +02:00
typeinfotest.cpp Remove BCC-specific hdrstop pragma from everywhere 2020-10-12 21:58:37 +02:00