From 83eca9a087e569bcdeaaeeddab84c9524952d23e Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 16 Apr 2021 10:33:56 +0200 Subject: Mark obsolete QMessageBox members as deprecated Those overloads have been documented as obsolete, but never been deprecated. Add the deprecation macros to trigger warnings as of Qt 6.2. The overloads taking a single StandardButton should not be deprecated until Qt 7, as otherwise porting from old to new API will require an unnecessary cast to StandardButtons for calls with only a single enum value. The unit test explicitly tests the deprecated members, so disable warnings there. Fixes: QTBUG-92483 Change-Id: I283ddce4681eafda2378607f999946e56bbb777e Reviewed-by: Richard Moe Gustavsen --- tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/auto/widgets/dialogs') diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp index ce84459973..4210c428ec 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp @@ -388,6 +388,8 @@ void tst_QMessageBox::staticSourceCompat() int ret; // source compat tests for < 4.2 +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED ExecCloseHelper closeHelper; closeHelper.start(Qt::Key_Enter); ret = QMessageBox::information(nullptr, "title", "text", QMessageBox::Yes, QMessageBox::No); @@ -438,10 +440,13 @@ void tst_QMessageBox::staticSourceCompat() QCOMPARE(ret, 1); QVERIFY(closeHelper.done()); } +QT_WARNING_POP } void tst_QMessageBox::instanceSourceCompat() { +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QMessageBox mb("Application name here", "Saving the file will overwrite the original file on the disk.\n" "Do you really want to save?", @@ -466,6 +471,7 @@ void tst_QMessageBox::instanceSourceCompat() closeHelper.start(QKeyCombination(Qt::ALT | Qt::Key_Z).toCombined(), &mb); QCOMPARE(mb.exec(), 1); #endif +QT_WARNING_POP } void tst_QMessageBox::detailsText() @@ -546,8 +552,11 @@ void tst_QMessageBox::incorrectDefaultButton() closeHelper.start(Qt::Key_Escape); QTest::ignoreMessage(QtWarningMsg, "QDialogButtonBox::createButton: Invalid ButtonRole, button not added"); QTest::ignoreMessage(QtWarningMsg, "QDialogButtonBox::createButton: Invalid ButtonRole, button not added"); +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED //do not crash here -> call old function of QMessageBox in this case QMessageBox::question(nullptr, "", "I've been hit!",QMessageBox::Ok | QMessageBox::Cancel,QMessageBox::Save | QMessageBox::Cancel,QMessageBox::Ok); +QT_WARNING_POP QVERIFY(closeHelper.done()); } -- cgit v1.2.3