summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-11-04 09:27:21 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-11-04 13:43:29 +0000
commit3dbdc367ffa50b1482d037c956336c809e53a0e6 (patch)
tree0b881c41590cc5cb9ca111e182147af787f58b1f /tests/auto
parent1c01cfa07734a299ed5f4c3489b140009a7cad45 (diff)
Suppress the modal window handling for dialogs embedded into QGraphicsView.
A dialog embedded into QGraphicsView has Qt::WA_DontShowOnScreen set (similar to a native dialog). It must not trigger the modal handling though as not to lock up. Task-number: QTBUG-49124 Change-Id: I22ce3f18d01df017b9317666770686bd4491387f Reviewed-by: Andreas Aardal Hanssen <andreas@hanssen.name>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
index 2982d80477..d5769554be 100644
--- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
+++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp
@@ -42,6 +42,8 @@
#include <QVBoxLayout>
#include <QSizeGrip>
#include <QDesktopWidget>
+#include <QGraphicsProxyWidget>
+#include <QGraphicsView>
#include <QWindow>
#include <private/qguiapplication_p.h>
#include <qpa/qplatformtheme.h>
@@ -80,6 +82,7 @@ private slots:
void snapToDefaultButton();
void transientParent_data();
void transientParent();
+ void dialogInGraphicsView();
private:
QDialog *testWidget;
@@ -118,9 +121,11 @@ public:
class ToolDialog : public QDialog
{
public:
- ToolDialog(QWidget *parent = 0) : QDialog(parent, Qt::Tool), mWasActive(false), tId(-1) {
- }
+ ToolDialog(QWidget *parent = 0)
+ : QDialog(parent, Qt::Tool), mWasActive(false), mWasModalWindow(false), tId(-1) {}
+
bool wasActive() const { return mWasActive; }
+ bool wasModalWindow() const { return mWasModalWindow; }
int exec() {
tId = startTimer(300);
@@ -131,12 +136,14 @@ protected:
if (tId == event->timerId()) {
killTimer(tId);
mWasActive = isActiveWindow();
+ mWasModalWindow = QGuiApplication::modalWindow() == windowHandle();
reject();
}
}
private:
int mWasActive;
+ bool mWasModalWindow;
int tId;
};
@@ -616,5 +623,27 @@ void tst_QDialog::transientParent()
QCOMPARE(dialog.windowHandle()->transientParent(), topLevel.windowHandle());
}
+void tst_QDialog::dialogInGraphicsView()
+{
+ // QTBUG-49124: A dialog embedded into QGraphicsView has Qt::WA_DontShowOnScreen
+ // set (as has a native dialog). It must not trigger the modal handling though
+ // as not to lock up.
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ view.setWindowTitle(QTest::currentTestFunction());
+ const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry();
+ view.resize(availableGeometry.size() / 2);
+ view.move(availableGeometry.left() + availableGeometry.width() / 4,
+ availableGeometry.top() + availableGeometry.height() / 4);
+ ToolDialog *dialog = new ToolDialog;
+ scene.addWidget(dialog);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ for (int i = 0; i < 3; ++i) {
+ dialog->exec();
+ QVERIFY(!dialog->wasModalWindow());
+ }
+}
+
QTEST_MAIN(tst_QDialog)
#include "tst_qdialog.moc"