From 1abfd204ed2ef6fdb996455c6c1d4ed2339126ac Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Fri, 13 Aug 2021 18:26:03 -0700 Subject: [PATCH] Entity tree: prevent creation of repeated entity items Signed-off-by: Louise Poubel --- src/gui/plugins/entity_tree/EntityTree.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/plugins/entity_tree/EntityTree.cc b/src/gui/plugins/entity_tree/EntityTree.cc index 8a0ae74152..79de5dfb7f 100644 --- a/src/gui/plugins/entity_tree/EntityTree.cc +++ b/src/gui/plugins/entity_tree/EntityTree.cc @@ -132,6 +132,13 @@ void TreeModel::AddEntity(unsigned int _entity, const QString &_entityName, return; } + if (this->entityItems.find(_entity) != this->entityItems.end()) + { + ignwarn << "Internal error: Trying to create item for entity [" << _entity + << "], but entity already has an item." << std::endl; + return; + } + // New entity item auto entityItem = new QStandardItem(_entityName); entityItem->setData(_entityName, this->roleNames().key("entityName"));