[vlc-devel] [PATCH v2 07/13] qt: medialib: pass loader via a raw pointer
    Romain Vimont 
    rom1v at videolabs.io
       
    Thu Nov 26 17:10:39 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 15930aaf63..0403a11d24 100644
--- a/modules/gui/qt/medialibrary/mlbasemodel.hpp
+++ b/modules/gui/qt/medialibrary/mlbasemodel.hpp
@@ -217,8 +217,8 @@ protected:
         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, &BaseListCache::localDataChanged,
                 this, &MLBaseModel::onLocalDataChanged);
 
diff --git a/modules/gui/qt/util/listcache.hpp b/modules/gui/qt/util/listcache.hpp
index d7d423da81..c762e84ede 100644
--- a/modules/gui/qt/util/listcache.hpp
+++ b/modules/gui/qt/util/listcache.hpp
@@ -75,8 +75,8 @@ class ListCache : public BaseListCache
 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