From b4b28fcd44dc96d4e7786c9c6aecd5deb799cfcc Mon Sep 17 00:00:00 2001 From: Prince Gupta Date: Wed, 13 Dec 2023 18:31:57 +0530 Subject: [PATCH] qt: fix cleanup of cache reverts 018f4890c161b3d1179771b8fd5f9987f1f172fa it was not that m_cachedData was deleted (see commit above) but the parent cache itself was deleted after emitting a signal in its member function fix: don't instantly clean up the cache in the source when requested since the requester can be the cache itself. fixes empty label is not visible in any view fixes model is always in a loading state --- modules/gui/qt/util/base_model_p.hpp | 5 ++++- modules/gui/qt/util/listcache.hxx | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/gui/qt/util/base_model_p.hpp b/modules/gui/qt/util/base_model_p.hpp index db73bb3b63..81ddb65304 100644 --- a/modules/gui/qt/util/base_model_p.hpp +++ b/modules/gui/qt/util/base_model_p.hpp @@ -83,7 +83,10 @@ protected: { Q_Q(BaseModel); emit q->beginResetModel(); - cache.reset(); + // 'abandon' existing cache and queue it for deletion + cache->disconnect(q); + cache->deleteLater(); + cache.release(); emit q->endResetModel(); validateCache(); } diff --git a/modules/gui/qt/util/listcache.hxx b/modules/gui/qt/util/listcache.hxx index 3ae0d8cd2f..0442c0f7b2 100644 --- a/modules/gui/qt/util/listcache.hxx +++ b/modules/gui/qt/util/listcache.hxx @@ -482,8 +482,6 @@ void ListCache::asyncCountAndLoad() ? std::min(m_limit, maximumCount) : maximumCount; - if (queryCount == 0) - return; //note: should we drop items past queryCount? m_cachedData = std::make_unique(std::move(list), queryCount,