diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | src/imports/controls/qquicktheme.cpp | 11 | ||||
-rw-r--r-- | tests/auto/auto.pro | 3 | ||||
-rw-r--r-- | tests/auto/theme/data/tst_theme.qml (renamed from tests/auto/controls/data/tst_theme.qml) | 0 | ||||
-rw-r--r-- | tests/auto/theme/theme.pro | 12 | ||||
-rw-r--r-- | tests/auto/theme/tst_theme.cpp | 57 |
6 files changed, 78 insertions, 6 deletions
@@ -18,6 +18,7 @@ /tests/auto/controls/tst_controls /tests/auto/sanity/tst_sanity /tests/auto/snippets/tst_snippets +/tests/auto/theme/tst_theme /tests/benchmarks/creationtime/tst_creationtime /tests/benchmarks/objectcount/tst_objectcount diff --git a/src/imports/controls/qquicktheme.cpp b/src/imports/controls/qquicktheme.cpp index 395d60d7..7fec28c9 100644 --- a/src/imports/controls/qquicktheme.cpp +++ b/src/imports/controls/qquicktheme.cpp @@ -102,11 +102,12 @@ Q_GLOBAL_STATIC_WITH_ARGS(QQuickThemeData, globalThemeData, (QString::fromLatin1 static QQuickThemeAttached *themeInstance(QQmlEngine *engine) { - static QHash<QQmlEngine *, QQuickThemeAttached *> themes; - QHash<QQmlEngine *, QQuickThemeAttached *>::iterator it = themes.find(engine); - if (it == themes.end()) - it = themes.insert(engine, new QQuickThemeAttached(*globalThemeData(), engine)); - return it.value(); + QQuickThemeAttached *theme = engine->property("_q_quicktheme").value<QQuickThemeAttached *>(); + if (!theme) { + theme = new QQuickThemeAttached(*globalThemeData(), engine); + engine->setProperty("_q_quicktheme", QVariant::fromValue(theme)); + } + return theme; } static QQuickThemeAttached *attachedTheme(QObject *object) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 2d12e08c..ff3d32e1 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -6,4 +6,5 @@ SUBDIRS += \ calendar \ controls \ sanity \ - snippets + snippets \ + theme diff --git a/tests/auto/controls/data/tst_theme.qml b/tests/auto/theme/data/tst_theme.qml index 4f94f2f5..4f94f2f5 100644 --- a/tests/auto/controls/data/tst_theme.qml +++ b/tests/auto/theme/data/tst_theme.qml diff --git a/tests/auto/theme/theme.pro b/tests/auto/theme/theme.pro new file mode 100644 index 00000000..e8d1133a --- /dev/null +++ b/tests/auto/theme/theme.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +TARGET = tst_theme +CONFIG += qmltestcase + +SOURCES += \ + $$PWD/tst_theme.cpp + +OTHER_FILES += \ + $$PWD/data/* + +TESTDATA += \ + $$PWD/data/tst_* diff --git a/tests/auto/theme/tst_theme.cpp b/tests/auto/theme/tst_theme.cpp new file mode 100644 index 00000000..daa1b1fe --- /dev/null +++ b/tests/auto/theme/tst_theme.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtQuickTest/quicktest.h> +#include <QtGui/qguiapplication.h> +#include <QtQml/qqmlapplicationengine.h> + +// based on QUICK_TEST_MAIN() defined in quicktest.h +int main(int argc, char **argv) +{ + QTEST_ADD_GPU_BLACKLIST_SUPPORT + QTEST_SET_MAIN_SOURCE_PATH + + { + // QTBUG-48651 + QGuiApplication app(argc, argv); + QQmlApplicationEngine engine; + engine.loadData("import Qt.labs.controls 1.0; Slider { } "); + if (engine.rootObjects().isEmpty()) + return -1; + } + + return quick_test_main(argc, argv, "tst_theme", QUICK_TEST_SOURCE_DIR); +} |