From 5c8c39cc334151fa889ae2d41a8fae3dc7c3da76 Mon Sep 17 00:00:00 2001 From: maelstrom Date: Fri, 11 Jul 2025 09:35:49 +0200 Subject: [PATCH] fix(editor): editing individual component of Vector3 in properties resulted in a crash --- editor/panes/propertiesview.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/editor/panes/propertiesview.cpp b/editor/panes/propertiesview.cpp index 61b3841..f1ebdc4 100644 --- a/editor/panes/propertiesview.cpp +++ b/editor/panes/propertiesview.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -24,6 +23,14 @@ #include #include +QDoubleSpinBox* makeDoubleSpinBox(QWidget* parent = nullptr) { + QDoubleSpinBox* spinBox = new QDoubleSpinBox(parent); + spinBox->setMaximum(INFINITY); + spinBox->setMinimum(-INFINITY); + spinBox->setDecimals(4); + return spinBox; +} + class PropertiesItemDelegate : public QStyledItemDelegate { PropertiesView* view; public: @@ -64,7 +71,7 @@ public: Vector3 vector = currentValue.get(); float value = componentName == "X" ? vector.X() : componentName == "Y" ? vector.Y() : componentName == "Z" ? vector.Z() : 0; - QDoubleSpinBox* spinBox = new QDoubleSpinBox(parent); + QDoubleSpinBox* spinBox = makeDoubleSpinBox(parent); spinBox->setValue(value); return spinBox; @@ -75,9 +82,9 @@ public: if (meta.type.descriptor == &FLOAT_TYPE) { QDoubleSpinBox* spinBox = new QDoubleSpinBox(parent); - spinBox->setValue(currentValue.get()); spinBox->setMinimum(-INFINITY); spinBox->setMaximum(INFINITY); + spinBox->setValue(currentValue.get()); if (meta.flags & PROP_UNIT_FLOAT) { spinBox->setMinimum(0); @@ -221,7 +228,8 @@ public: : componentName == "Z" ? Vector3(prev.X(), prev.Y(), value) : prev; inst->SetProperty(propertyName, newVector).expect(); - view->rebuildCompositeProperty(view->itemFromIndex(index.parent()), &Vector3::TYPE, newVector); + // SetProperty above already causes the composite to be rebuilt. So we get rid of it here to prevent errors + // view->rebuildCompositeProperty(view->itemFromIndex(index.parent()), &Vector3::TYPE, newVector); return; }