QTest: add removed_api.cpp and move deprecated functions to it

QtTest is not under the same Binary Compatibility guarantees as the
other modules, but let's try and do it where it's easy.

The toString() method can simply be removed from the header because it's
not a member function. Its deprecation wasn't marked with a version
number, so it starts now with 6.8.

Change-Id: Ie28eadac333c4bcd8c08fffd17c54faca7057b9c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
Thiago Macieira 2024-04-11 12:13:26 -07:00 committed by Ivan Solovev
parent eccaf0abec
commit b7fb9d8150
4 changed files with 32 additions and 8 deletions

View File

@ -13,6 +13,7 @@ qt_internal_add_module(Test
EXCEPTIONS
SOURCES
3rdparty/cycle_p.h
removed_api.cpp # keep first
qabstracttestlogger.cpp qabstracttestlogger_p.h
qasciikey.cpp
qbenchmark.cpp qbenchmark.h qbenchmark_p.h
@ -70,6 +71,8 @@ qt_internal_add_module(Test
QT_NO_MESSAGELOGCONTEXT
LIBRARIES
Qt::CorePrivate
NO_PCH_SOURCES
removed_api.cpp
PUBLIC_LIBRARIES
Qt::Core
PRIVATE_MODULE_INTERFACE

View File

@ -3060,11 +3060,6 @@ char *QTest::toString(const char *str)
/*! \internal
*/
char *QTest::toString(const volatile void *p) // Use volatile to match compare_ptr_helper()
{
return QTest::toString(const_cast<const void *>(p));
}
char *QTest::toString(const void *p)
{
char *msg = new char[128];
qsnprintf(msg, 128, "%p", p);

View File

@ -402,7 +402,6 @@ namespace QTest
Q_TESTLIB_EXPORT char *toPrettyUnicode(QStringView string);
Q_TESTLIB_EXPORT char *toString(const char *);
Q_TESTLIB_EXPORT char *toString(const volatile void *);
Q_TESTLIB_EXPORT char *toString(const void *); // ### FIXME: Qt 7: Remove
Q_TESTLIB_EXPORT char *toString(const volatile QObject *);
Q_TESTLIB_EXPORT void qInit(QObject *testObject, int argc = 0, char **argv = nullptr);
@ -495,8 +494,6 @@ namespace QTest
Q_TESTLIB_EXPORT Qt::Key asciiToKey(char ascii);
Q_TESTLIB_EXPORT char keyToAscii(Qt::Key key);
// ### TODO: remove QTestResult::compare() overload that takes char * values
// when this overload is removed.
#if QT_DEPRECATED_SINCE(6, 4)
QT_DEPRECATED_VERSION_X_6_4("use an overload that takes function_ref as parameters, "
"or an overload that takes only failure message, if you "

View File

@ -0,0 +1,29 @@
// Copyright (C) 2021 The Qt Company Ltd.
// Copyright (C) 2024 Intel Corporation.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#define QT_TESTLIB_BUILD_REMOVED_API
#include "qtest.h"
#if QT_TESTLIB_REMOVED_SINCE(6, 8)
QT_BEGIN_NAMESPACE
namespace QTest {
Q_TESTLIB_EXPORT char *toString(const void *p)
{
const volatile void *ptr = p;
return toString(ptr);
}
} // namespace QTest
QT_END_NAMESPACE
// #include "qotherheader.h"
// implement removed functions from qotherheader.h
// order sections alphabetically to reduce chances of merge conflicts
#endif // QT_TESTLIB_REMOVED_SINCE(6, 8)