Fix QErrorMessage test when using native dialogs
When the test is showing the error message over and over, it's not waiting for the native dialog to actually become visible, and as a result, hiding it has no effect and won't result in a call to processResponse, where we got rid of the native dialog. To fix this we explicitly release the native dialog when encountering this corner case. Add logic to QErrorMessage to test both native and non native dialogs. Pick-to: 6.5 Change-Id: I19ac3f463997aed1e66f646fdfcbb4d2459116d1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
08b71d8619
commit
349fda471e
@ -307,6 +307,8 @@ void QCocoaMessageDialog::hide()
|
||||
}
|
||||
} else {
|
||||
qCDebug(lcQpaDialogs) << "No need to hide already hidden" << m_alert;
|
||||
auto alert = std::exchange(m_alert, nil);
|
||||
[alert autorelease];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ qt_internal_add_test(tst_qerrormessage
|
||||
tst_qerrormessage.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::GuiPrivate
|
||||
Qt::Widgets
|
||||
)
|
||||
|
||||
|
@ -5,16 +5,38 @@
|
||||
#include <QDebug>
|
||||
#include <QCheckBox>
|
||||
|
||||
#include <qpa/qplatformtheme.h>
|
||||
#include <private/qguiapplication_p.h>
|
||||
|
||||
class tst_QErrorMessage : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void initTestCase_data();
|
||||
void init();
|
||||
|
||||
void dontShowAgain();
|
||||
void dontShowCategoryAgain();
|
||||
|
||||
};
|
||||
|
||||
void tst_QErrorMessage::initTestCase_data()
|
||||
{
|
||||
QTest::addColumn<bool>("useNativeDialog");
|
||||
QTest::newRow("widget") << false;
|
||||
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
|
||||
if (theme->usePlatformNativeDialog(QPlatformTheme::MessageDialog))
|
||||
QTest::newRow("native") << true;
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QErrorMessage::init()
|
||||
{
|
||||
QFETCH_GLOBAL(bool, useNativeDialog);
|
||||
qApp->setAttribute(Qt::AA_DontUseNativeDialogs, !useNativeDialog);
|
||||
}
|
||||
|
||||
void tst_QErrorMessage::dontShowAgain()
|
||||
{
|
||||
QString plainString = QLatin1String("foo");
|
||||
|
Loading…
Reference in New Issue
Block a user