diff options
-rw-r--r-- | common/modelresult.cpp | 4 | ||||
-rw-r--r-- | tests/querytest.cpp | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/common/modelresult.cpp b/common/modelresult.cpp index 95f4643..4295a44 100644 --- a/common/modelresult.cpp +++ b/common/modelresult.cpp | |||
@@ -318,7 +318,9 @@ template <class T, class Ptr> | |||
318 | void ModelResult<T, Ptr>::remove(const Ptr &value) | 318 | void ModelResult<T, Ptr>::remove(const Ptr &value) |
319 | { | 319 | { |
320 | auto childId = qHash(*value); | 320 | auto childId = qHash(*value); |
321 | auto id = parentId(value); | 321 | //The removed entity will have no properties, but we at least need the parent property. |
322 | auto actualEntity = mEntities.value(childId); | ||
323 | auto id = parentId(actualEntity); | ||
322 | auto parent = createIndexFromId(id); | 324 | auto parent = createIndexFromId(id); |
323 | SinkTraceCtx(mLogCtx) << "Removed entity" << childId; | 325 | SinkTraceCtx(mLogCtx) << "Removed entity" << childId; |
324 | auto index = mTree[id].indexOf(childId); | 326 | auto index = mTree[id].indexOf(childId); |
diff --git a/tests/querytest.cpp b/tests/querytest.cpp index 3b62f56..6279fa9 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp | |||
@@ -263,7 +263,6 @@ private slots: | |||
263 | query.resourceFilter("sink.dummy.instance1"); | 263 | query.resourceFilter("sink.dummy.instance1"); |
264 | query.requestTree<Folder::Parent>(); | 264 | query.requestTree<Folder::Parent>(); |
265 | 265 | ||
266 | // We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data | ||
267 | auto model = Sink::Store::loadModel<Folder>(query); | 266 | auto model = Sink::Store::loadModel<Folder>(query); |
268 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 267 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
269 | QCOMPARE(model->rowCount(), 1); | 268 | QCOMPARE(model->rowCount(), 1); |
@@ -274,9 +273,15 @@ private slots: | |||
274 | VERIFYEXEC(Sink::Store::create<Folder>(subfolder)); | 273 | VERIFYEXEC(Sink::Store::create<Folder>(subfolder)); |
275 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1")); | 274 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1")); |
276 | 275 | ||
276 | //Ensure the folder appears | ||
277 | model->fetchMore(model->index(0, 0)); | 277 | model->fetchMore(model->index(0, 0)); |
278 | QTRY_VERIFY(model->data(model->index(0, 0), Sink::Store::ChildrenFetchedRole).toBool()); | 278 | QTRY_VERIFY(model->data(model->index(0, 0), Sink::Store::ChildrenFetchedRole).toBool()); |
279 | QCOMPARE(model->rowCount(model->index(0, 0)), 1); | 279 | QCOMPARE(model->rowCount(model->index(0, 0)), 1); |
280 | |||
281 | //...and dissapears again after removal | ||
282 | VERIFYEXEC(Sink::Store::remove<Folder>(subfolder)); | ||
283 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue("sink.dummy.instance1")); | ||
284 | QTRY_COMPARE(model->rowCount(model->index(0, 0)), 0); | ||
280 | } | 285 | } |
281 | 286 | ||
282 | void testMailByMessageId() | 287 | void testMailByMessageId() |