From e5002225dbe4092f5d4e219d8eec7015578f9265 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 22 Feb 2018 13:58:28 +0100 Subject: Handle the removal of the last item cleanly --- common/datastorequery.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/common/datastorequery.cpp b/common/datastorequery.cpp index dacc8ab..9e61a3d 100644 --- a/common/datastorequery.cpp +++ b/common/datastorequery.cpp @@ -345,11 +345,14 @@ public: callback({entity, Sink::Operation_Removal}); }); - //add new result - mSelectedValues.insert(reductionValueBa, selectionResult.selection); - readEntity(selectionResult.selection, [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { - callback({entity, Sink::Operation_Creation, selectionResult.aggregateValues, selectionResult.aggregateIds}); - }); + //If the last item has been removed, then there's nothing to add + if (!selectionResult.selection.isEmpty()) { + //add new result + mSelectedValues.insert(reductionValueBa, selectionResult.selection); + readEntity(selectionResult.selection, [&](const Sink::ApplicationDomain::ApplicationDomainType &entity, Sink::Operation) { + callback({entity, Sink::Operation_Creation, selectionResult.aggregateValues, selectionResult.aggregateIds}); + }); + } } } } -- cgit v1.2.3