From 720079d6a839b4d03eb0ceaa06d0ad2b446f7de1 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 11 Feb 2017 12:04:38 +0100 Subject: Don't emit superfluous remove signals. We often let removal updates through and expect the model to deal with superfluous updates, this now actually implements that. --- common/modelresult.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'common') diff --git a/common/modelresult.cpp b/common/modelresult.cpp index 0825518..f935419 100644 --- a/common/modelresult.cpp +++ b/common/modelresult.cpp @@ -228,12 +228,14 @@ void ModelResult::remove(const Ptr &value) auto parent = createIndexFromId(id); SinkTraceCtx(mLogCtx) << "Removed entity" << childId; auto index = mTree[id].indexOf(childId); - beginRemoveRows(parent, index, index); - mEntities.remove(childId); - mTree[id].removeAll(childId); - mParents.remove(childId); - // TODO remove children - endRemoveRows(); + if (index >= 0) { + beginRemoveRows(parent, index, index); + mEntities.remove(childId); + mTree[id].removeAll(childId); + mParents.remove(childId); + // TODO remove children + endRemoveRows(); + } } template -- cgit v1.2.3