aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickcontrolstestutils/controlstestutils.cpp
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2022-09-03 11:50:14 +0200
committerMitch Curtis <mitch.curtis@qt.io>2022-09-18 04:32:10 +0800
commit7bcfc16ca2790b387b734f1f37eb43198f05994a (patch)
tree7f0013cbd3a59315c2e8b26a0d6d6196d5741038 /src/quickcontrolstestutils/controlstestutils.cpp
parent843b8d126d87697379f8bc35a2b19b8cc169336a (diff)
Fix warning from ignoring return of [nodiscard] method
Compiler warns: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result] Pick-to: 6.4 Change-Id: If10d41fad7dc77b36eecc8725de178b0908f32de Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/quickcontrolstestutils/controlstestutils.cpp')
-rw-r--r--src/quickcontrolstestutils/controlstestutils.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/quickcontrolstestutils/controlstestutils.cpp b/src/quickcontrolstestutils/controlstestutils.cpp
index de7d38db32..662633c7b6 100644
--- a/src/quickcontrolstestutils/controlstestutils.cpp
+++ b/src/quickcontrolstestutils/controlstestutils.cpp
@@ -17,11 +17,19 @@ QQuickControlsTestUtils::QQuickControlsApplicationHelper::QQuickControlsApplicat
appWindow = qobject_cast<QQuickApplicationWindow*>(cleanup.data());
}
+/*!
+ \internal
+
+ If \a style is different from the current style, this function will
+ recreate the QML engine, clear type registrations and set the new style.
+
+ Returns \c true if successful or if \c style is already set.
+*/
bool QQuickControlsTestUtils::QQuickStyleHelper::updateStyle(const QString &style)
{
// If it's not the first time a style has been set and the new style is not different, do nothing.
if (!currentStyle.isEmpty() && style == currentStyle)
- return false;
+ return true;
engine.reset();
currentStyle = style;
@@ -31,8 +39,9 @@ bool QQuickControlsTestUtils::QQuickStyleHelper::updateStyle(const QString &styl
QQmlComponent component(engine.data());
component.setData(QString::fromUtf8("import QtQuick\nimport QtQuick.Controls\n Control { }").toUtf8(), QUrl());
-
- return true;
+ if (!component.isReady())
+ qWarning() << "Failed to load component:" << component.errorString();
+ return component.isReady();
}
void QQuickControlsTestUtils::forEachControl(QQmlEngine *engine, const QString &qqc2ImportPath,