[vlc-devel] [PATCH 07/13] qt: medialib: pass loader via a raw pointer
Romain Vimont
rom1v at videolabs.io
Mon Nov 23 17:30:21 CET 2020
Currently, the loader is owned by MLModelCache, but in the future it
might outlive it: database queries will be executed from a separate
thread, and MLModelCache could be deleted while an asynchronous request
is running.
To prepare for this change, do not require to receive the loader via a
std::unique_ptr (let the cache wrap it).
---
modules/gui/qt/medialibrary/mlbasemodel.hpp | 4 ++--
modules/gui/qt/util/listcache.hpp | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/modules/gui/qt/medialibrary/mlbasemodel.hpp b/modules/gui/qt/medialibrary/mlbasemodel.hpp
index 7581c2fae9..00911c5547 100644
--- a/modules/gui/qt/medialibrary/mlbasemodel.hpp
+++ b/modules/gui/qt/medialibrary/mlbasemodel.hpp
@@ -216,8 +216,8 @@ public:
if (m_cache)
return;
- auto loader = std::make_unique<Loader>(*this);
- m_cache.reset(new ListCache<std::unique_ptr<T>>(std::move(loader)));
+ auto loader = new Loader(*this);
+ m_cache.reset(new ListCache<std::unique_ptr<T>>(loader));
connect(&*m_cache, &ListCacheBase::localDataChanged,
this, &MLBaseModel::onLocalDataChanged);
diff --git a/modules/gui/qt/util/listcache.hpp b/modules/gui/qt/util/listcache.hpp
index d18abe8eb7..56016dce77 100644
--- a/modules/gui/qt/util/listcache.hpp
+++ b/modules/gui/qt/util/listcache.hpp
@@ -75,8 +75,8 @@ class ListCache : public ListCacheBase
public:
static constexpr ssize_t COUNT_UNINITIALIZED = -1;
- ListCache(std::unique_ptr<ListCacheLoader<T>> loader, size_t chunkSize = 100)
- : m_loader(std::move(loader))
+ ListCache(ListCacheLoader<T> *loader, size_t chunkSize = 100)
+ : m_loader(loader)
, m_chunkSize(chunkSize) {}
/**
--
2.29.2
More information about the vlc-devel
mailing list