From b443fb28911d939990db9ec7d0a0ab1282027995 Mon Sep 17 00:00:00 2001 From: Pierre Lamot <pierre@videolabs.io> Date: Tue, 10 Dec 2024 16:21:14 +0100 Subject: [PATCH] qt: fix assertion in asyncFetchMore when cache tries to recursively refer items MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The failling scenario is * Count&Load task issued (task n°1) * model need reset (thumbnail is updated for instance) => `needReload = true` * Count&Load task (n°1) is resolved * diff util insert/remove rows * Callback from model change ask to refer an item beyond the cache * refer issue a new 'fetch more' request (n°2) as m_countTask is 0 * as `needReload == true`, cache is moved to oldCache, new count&load request is issued (n° 3) * task n°2 resolve, cache is null, assertion fails by moving the `m_countTask` reset after the model update, we ensure that `refer` won't start a new request while the model is still propagating the update. --- modules/gui/qt/util/listcache.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/gui/qt/util/listcache.hxx b/modules/gui/qt/util/listcache.hxx index c1c4c2e8b27e..904df99021a7 100644 --- a/modules/gui/qt/util/listcache.hxx +++ b/modules/gui/qt/util/listcache.hxx @@ -521,8 +521,6 @@ void ListCache<T>::asyncCountAndLoad() if (m_countTask != taskId) return; - m_countTask = 0; - //quite unlikley but model may change between count and load if (unlikely(list.size() > maximumCount)) { @@ -556,6 +554,8 @@ void ListCache<T>::asyncCountAndLoad() emit localSizeChanged(0, m_cachedData->maximumCount); } + m_countTask = 0; + if (m_needReload) { m_needReload = false; -- GitLab