summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2013-08-21 10:08:50 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-15 08:14:48 +0200
commit37ca2224eca671200a2710f57f970d2993e62aa5 (patch)
tree79800f85b1d34e09fd9b2a16b4e5079152db4b8f /tests
parent5c301f4121b4395b968ef3d6404986326ce70048 (diff)
QFileDialog: don't create widgets if the platform dialog will be used
This is a performance and memory optimization which also fixes bugs that are related to creating widgets, file system models etc. despite using platform native dialogs. Similar to 785bc64f8e743ac269f15cbe7fecba93d3d507ac for QColorDialog. Task-number: QTBUG-33039 Change-Id: Ia1aa7ec1f43b47006b9ebd377aed15c958538a17 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index 81b69f6b89..8bad4bb176 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -66,6 +66,8 @@
#include <private/qfilesystemmodel_p.h>
#include <private/qfiledialog_p.h>
#endif
+#include <private/qguiapplication_p.h>
+#include <qpa/qplatformtheme.h>
#include <QFileDialog>
#include <QFileSystemModel>
@@ -145,6 +147,7 @@ private slots:
void clearLineEdit();
void enableChooseButton();
void hooks();
+ void widgetlessNativeDialog();
#ifdef Q_OS_UNIX
#ifdef QT_BUILD_INTERNAL
void tildeExpansion_data();
@@ -1396,6 +1399,20 @@ void tst_QFiledialog::hooks()
QCOMPARE(QFileDialog::getSaveFileUrl(), QUrl("http://saveUrl"));
}
+void tst_QFiledialog::widgetlessNativeDialog()
+{
+ if (!QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(QPlatformTheme::FileDialog))
+ QSKIP("This platform always uses widgets to realize its QFileDialog, instead of the native file dialog.");
+ QFileDialog fd;
+ fd.setWindowModality(Qt::ApplicationModal);
+ fd.show();
+ QTRY_VERIFY(fd.isVisible());
+ QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model");
+ QVERIFY(!model);
+ QPushButton *button = fd.findChild<QPushButton*>();
+ QVERIFY(!button);
+}
+
#ifdef Q_OS_UNIX
#ifdef QT_BUILD_INTERNAL
void tst_QFiledialog::tildeExpansion_data()