From 30d00a7de2400d97b9241bfda96027e89952df80 Mon Sep 17 00:00:00 2001 From: maelstrom Date: Mon, 28 Apr 2025 01:27:12 +0200 Subject: [PATCH] fix(editor): properties view setting/unsetting anchored and locked properties erroneously --- editor/panes/propertiesview.cpp | 6 +++++- editor/panes/propertiesview.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/editor/panes/propertiesview.cpp b/editor/panes/propertiesview.cpp index d5c7d47..104c653 100644 --- a/editor/panes/propertiesview.cpp +++ b/editor/panes/propertiesview.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -340,6 +339,8 @@ void PropertiesView::setSelected(std::optional instance) { } void PropertiesView::propertyChanged(QTreeWidgetItem *item, int column) { + // Necessary because otherwise this will catch setCheckState from onPropertyUpdated + if (ignorePropertyUpdates) return; if (!item->parent() || (item->parent() && item->parent()->parent()) || currentInstance.expired()) return; InstanceRef inst = currentInstance.lock(); @@ -396,7 +397,10 @@ void PropertiesView::onPropertyUpdated(InstanceRef inst, std::string property, D if (item->data(0, Qt::DisplayRole).toString().toStdString() != property) continue; if (meta.type == &Data::Bool::TYPE) { + // This is done because otherwise propertyChanged will catch this change erroneously + ignorePropertyUpdates = true; item->setCheckState(1, (bool)currentValue.get() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked); + ignorePropertyUpdates = false; } else if (meta.type == &Color3::TYPE) { Color3 color = currentValue.get(); item->setData(1, Qt::DecorationRole, QColor::fromRgbF(color.R(), color.G(), color.B())); diff --git a/editor/panes/propertiesview.h b/editor/panes/propertiesview.h index 2a47886..7334bb3 100644 --- a/editor/panes/propertiesview.h +++ b/editor/panes/propertiesview.h @@ -11,6 +11,7 @@ namespace Data { class Variant; }; class PropertiesView : public QTreeWidget { Q_DECLARE_PRIVATE(QTreeView) + bool ignorePropertyUpdates = false; InstanceRefWeak currentInstance; void propertyChanged(QTreeWidgetItem *item, int column); void activateProperty(QTreeWidgetItem *item, int column);