summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp17
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h2
2 files changed, 17 insertions, 2 deletions
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
index da15c053..3b7194c7 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
@@ -585,8 +585,18 @@ auto InspectorControlModel::computeGroup(CInspectableBase* inspectable,
void InspectorControlModel::rebuildTree()
{
beginResetModel();
+ QVector<QObject *> deleteVector;
+ for (int i = 0; i < m_groupElements.count(); ++i) {
+ auto group = m_groupElements[i];
+ for (int p = 0; p < group.controlElements.count(); ++p)
+ deleteVector.append(group.controlElements[p].value<QObject *>());
+ }
m_groupElements = computeTree(m_inspectableBase);
endResetModel();
+
+ // Clean the old objects after reset is done so that qml will not freak out about null pointers
+ for (int i = 0; i < deleteVector.count(); ++i)
+ deleteVector[i]->deleteLater();
}
int InspectorControlModel::rowCount(const QModelIndex &parent) const
@@ -833,13 +843,20 @@ void InspectorControlModel::refreshTree()
rebuildTree();
} else {
// group structure is intact, let's walk to see which rows changed
+ QVector<QObject *> deleteVector;
long theCount = m_inspectableBase->GetGroupCount();
for (long theIndex = 0; theIndex < theCount; ++theIndex) {
if (isGroupRebuildRequired(m_inspectableBase, theIndex)) {
+ auto group = m_groupElements[theIndex];
+ for (int p = 0; p < group.controlElements.count(); ++p)
+ deleteVector.append(group.controlElements[p].value<QObject *>());
m_groupElements[theIndex] = computeGroup(m_inspectableBase, theIndex);
Q_EMIT dataChanged(index(theIndex), index(theIndex));
}
}
+ // Clean the old objects after refresh is done so that qml will not freak out
+ for (int i = 0; i < deleteVector.count(); ++i)
+ deleteVector[i]->deleteLater();
}
}
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h
index 9e0009f2..78f5378b 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h
@@ -160,8 +160,6 @@ private:
QVariantList controlElements;
~GroupInspectorControl() {
- //for (auto element : controlElements)
- // element.value<QObject *>()->deleteLater();
}
};