aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickcontrols2
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2020-08-27 15:15:21 +0200
committerMitch Curtis <mitch.curtis@qt.io>2020-08-27 20:16:30 +0200
commit6147b56c03a89bf8f3bfd88fc4838718e06ecb48 (patch)
tree3a47383d28b8626db044143642c05df21b4944cb /src/quickcontrols2
parent7f29e89c26ae2babc358b1c4e6f965af6ec759f4 (diff)
Fix crash when importing a style without first importing Controls
The following code import QtQuick import QtQuick.Controls.Material ApplicationWindow { width: 200 height: 200 visible: true } produced an error in Qt 5: QQmlApplicationEngine failed to load component qrc:/main.qml:4 ApplicationWindow is not a type In Qt 6, the types are provided by the qmldir, so the import will work, but as QtQuickControls2Plugin has not been loaded, there is no QQuickTheme object yet, and so the style will not work as expected (any colors, fonts, etc. from the theme will not be used by the style). Produce a warning for this scenario, and test each style to make sure that we don't crash. Fixes: QTBUG-86280 Change-Id: I99f940255f56da0522ad192ae5da4c9110ea308e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/quickcontrols2')
-rw-r--r--src/quickcontrols2/qquickstyleplugin.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/quickcontrols2/qquickstyleplugin.cpp b/src/quickcontrols2/qquickstyleplugin.cpp
index 1f1c3875..657b31fc 100644
--- a/src/quickcontrols2/qquickstyleplugin.cpp
+++ b/src/quickcontrols2/qquickstyleplugin.cpp
@@ -65,6 +65,9 @@ QString QQuickStylePlugin::name() const
void QQuickStylePlugin::registerTypes(const char *uri)
{
qCDebug(lcStylePlugin).nospace() << "registerTypes called with uri " << uri << "; plugin name is " << name();
+
+ if (!QQuickTheme::instance())
+ qWarning() << "QtQuick.Controls must be imported before importing" << baseUrl().toString();
}
void QQuickStylePlugin::unregisterTypes()