aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoris Verria <doris.verria@qt.io>2026-09-14 15:19:02 +0200
committerDoris Verria <doris.verria@qt.io>2026-09-16 17:48:28 +0000
commit22c8e90b85cf81ea886e780ff4041c87707c422d (patch)
tree478c6f2f5ed8fc1e4019de20f7bac0ecb6357478
parent813dbe6fb3ae5d4d2786d73a0b13c438761f5b1e (diff)
QStyleKitStyle: Don't change stylePath property if style fails to load
On a failed style load, we were keeping the previously loaded style, emit a warning, but updating the stylePath property. To not cause mismatches between what the actual loaded style reflects and stylePath skip updating the property at all. Pick-to: 6.12 Change-Id: Ia9881f2a5c8f29f8917aa9a8673cced3597f4b1b Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
-rw-r--r--src/labs/stylekit/widgets/qstylekitstyle.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/labs/stylekit/widgets/qstylekitstyle.cpp b/src/labs/stylekit/widgets/qstylekitstyle.cpp
index 36daeef5ea..f83b357de1 100644
--- a/src/labs/stylekit/widgets/qstylekitstyle.cpp
+++ b/src/labs/stylekit/widgets/qstylekitstyle.cpp
@@ -1643,6 +1643,7 @@ QStyleKitStyle::QStyleKitStyle(const QString &filePath)
Q_D(QStyleKitStyle);
d->stylePath = filePath;
if (!d->loadStyle()) {
+ d->stylePath.clear();
qWarning("QStyleKitStyle: Failed to load style from %s", qPrintable(filePath));
}
}
@@ -1687,14 +1688,17 @@ void QStyleKitStyle::setStylePath(const QString &filePath)
const QStringList oldThemeNames = availableThemeNames();
const QStringList oldCustomThemeNames = customThemeNames();
+ const QString previousPath = d->stylePath;
d->stylePath = filePath;
- if (d->loadStyle()) {
- d->updateStyle();
- if (const QStringList names = availableThemeNames(); names != oldThemeNames)
- emit availableThemeNamesChanged(names);
- if (const QStringList names = customThemeNames(); names != oldCustomThemeNames)
- emit customThemeNamesChanged(names);
+ if (!d->loadStyle()) {
+ d->stylePath = previousPath;
+ return;
}
+ d->updateStyle();
+ if (const QStringList names = availableThemeNames(); names != oldThemeNames)
+ emit availableThemeNamesChanged(names);
+ if (const QStringList names = customThemeNames(); names != oldCustomThemeNames)
+ emit customThemeNamesChanged(names);
emit stylePathChanged(d->stylePath);
}