mirror of
https://git.outfoxxed.me/quickshell/quickshell.git
synced 2026-04-10 06:11:54 +10:00
io/fileview: use QVariant when QJSValue cast fails in adapter prop read
A QVariant(QVariantMap) does not convert implicitly to a QVaraint(QJSValue), causing extra signals to be emitted if the old value was not updated by js (replaced by a QJSValue) before deserializing again.
This commit is contained in:
parent
aaff22f4b0
commit
ceac3c6cfa
2 changed files with 7 additions and 4 deletions
|
|
@ -67,6 +67,7 @@ set shell id.
|
||||||
- Fixed HyprlandFocusGrab crashing if windows were destroyed after being passed to it.
|
- Fixed HyprlandFocusGrab crashing if windows were destroyed after being passed to it.
|
||||||
- Fixed ScreencopyView pixelation when scaled.
|
- Fixed ScreencopyView pixelation when scaled.
|
||||||
- Fixed JsonAdapter crashing and providing bad data on read when using JsonObject.
|
- Fixed JsonAdapter crashing and providing bad data on read when using JsonObject.
|
||||||
|
- Fixed JsonAdapter sending unnecessary property changes for primitive values.
|
||||||
|
|
||||||
## Packaging Changes
|
## Packaging Changes
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -154,13 +154,15 @@ void JsonAdapter::deserializeRec(const QJsonObject& json, QObject* obj, const QM
|
||||||
auto jval = json.value(prop.name());
|
auto jval = json.value(prop.name());
|
||||||
|
|
||||||
if (prop.metaType() == QMetaType::fromType<QVariant>()) {
|
if (prop.metaType() == QMetaType::fromType<QVariant>()) {
|
||||||
auto variant = jval.toVariant();
|
auto newVariant = jval.toVariant();
|
||||||
auto oldValue = prop.read(obj).value<QJSValue>();
|
auto oldValue = prop.read(obj);
|
||||||
|
auto oldVariant =
|
||||||
|
oldValue.canConvert<QJSValue>() ? oldValue.value<QJSValue>().toVariant() : oldValue;
|
||||||
|
|
||||||
// Calling prop.write with a new QJSValue will cause a property update
|
// Calling prop.write with a new QJSValue will cause a property update
|
||||||
// even if content is identical.
|
// even if content is identical.
|
||||||
if (jval.toVariant() != oldValue.toVariant()) {
|
if (newVariant != oldVariant) {
|
||||||
auto jsValue = qmlEngine(this)->fromVariant<QJSValue>(jval.toVariant());
|
auto jsValue = qmlEngine(this)->fromVariant<QJSValue>(newVariant);
|
||||||
prop.write(obj, QVariant::fromValue(jsValue));
|
prop.write(obj, QVariant::fromValue(jsValue));
|
||||||
}
|
}
|
||||||
} else if (QMetaType::canView(prop.metaType(), QMetaType::fromType<JsonObject*>())) {
|
} else if (QMetaType::canView(prop.metaType(), QMetaType::fromType<JsonObject*>())) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue