Skip to content

Commit

Permalink
Fixed removal of object reference arrow when deleting target object
Browse files Browse the repository at this point in the history
Closes #2944
  • Loading branch information
bjorn committed Dec 8, 2020
1 parent e2cccee commit 403fc19
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/tiled/objectselectionitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,10 @@ void ObjectSelectionItem::objectsAboutToBeRemoved(const QList<MapObject *> &obje
delete mObjectLabels.take(object);

for (MapObject *object : objects) {
// Remove any references originating from this object
auto it = mReferencesBySourceObject.find(object);
if (it != mReferencesBySourceObject.end()) {
QList<ObjectReferenceItem*> &items = *it;
const QList<ObjectReferenceItem*> &items = *it;
for (auto item : items) {
auto &itemsByTarget = mReferencesByTargetObject[item->targetObject()];
itemsByTarget.removeOne(item);
Expand All @@ -570,6 +571,21 @@ void ObjectSelectionItem::objectsAboutToBeRemoved(const QList<MapObject *> &obje
}
mReferencesBySourceObject.erase(it);
}

// Remove any references pointing to this object
it = mReferencesByTargetObject.find(object);
if (it != mReferencesByTargetObject.end()) {
const QList<ObjectReferenceItem*> &items = *it;
for (auto item : items) {
auto &itemsBySource = mReferencesBySourceObject[item->sourceObject()];
itemsBySource.removeOne(item);
if (itemsBySource.isEmpty())
mReferencesBySourceObject.remove(item->sourceObject());

delete item;
}
mReferencesByTargetObject.erase(it);
}
}
}

Expand Down

0 comments on commit 403fc19

Please sign in to comment.