fix(editor): editing individual component of Vector3 in properties resulted in a crash
This commit is contained in:
parent
75f0892748
commit
5c8c39cc33
1 changed files with 12 additions and 4 deletions
|
@ -15,7 +15,6 @@
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <cfloat>
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
|
@ -24,6 +23,14 @@
|
||||||
#include <qnamespace.h>
|
#include <qnamespace.h>
|
||||||
#include <qtreewidget.h>
|
#include <qtreewidget.h>
|
||||||
|
|
||||||
|
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 {
|
class PropertiesItemDelegate : public QStyledItemDelegate {
|
||||||
PropertiesView* view;
|
PropertiesView* view;
|
||||||
public:
|
public:
|
||||||
|
@ -64,7 +71,7 @@ public:
|
||||||
Vector3 vector = currentValue.get<Vector3>();
|
Vector3 vector = currentValue.get<Vector3>();
|
||||||
float value = componentName == "X" ? vector.X() : componentName == "Y" ? vector.Y() : componentName == "Z" ? vector.Z() : 0;
|
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);
|
spinBox->setValue(value);
|
||||||
|
|
||||||
return spinBox;
|
return spinBox;
|
||||||
|
@ -75,9 +82,9 @@ public:
|
||||||
|
|
||||||
if (meta.type.descriptor == &FLOAT_TYPE) {
|
if (meta.type.descriptor == &FLOAT_TYPE) {
|
||||||
QDoubleSpinBox* spinBox = new QDoubleSpinBox(parent);
|
QDoubleSpinBox* spinBox = new QDoubleSpinBox(parent);
|
||||||
spinBox->setValue(currentValue.get<float>());
|
|
||||||
spinBox->setMinimum(-INFINITY);
|
spinBox->setMinimum(-INFINITY);
|
||||||
spinBox->setMaximum(INFINITY);
|
spinBox->setMaximum(INFINITY);
|
||||||
|
spinBox->setValue(currentValue.get<float>());
|
||||||
|
|
||||||
if (meta.flags & PROP_UNIT_FLOAT) {
|
if (meta.flags & PROP_UNIT_FLOAT) {
|
||||||
spinBox->setMinimum(0);
|
spinBox->setMinimum(0);
|
||||||
|
@ -221,7 +228,8 @@ public:
|
||||||
: componentName == "Z" ? Vector3(prev.X(), prev.Y(), value) : prev;
|
: componentName == "Z" ? Vector3(prev.X(), prev.Y(), value) : prev;
|
||||||
|
|
||||||
inst->SetProperty(propertyName, newVector).expect();
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue