vlc | branch: master | Romain Vimont <[email protected]> | Fri Oct 23 17:25:47 
2020 +0200| [40cbc29557cfc92f8c6fd1afc21e46228a050a91] | committer: Pierre Lamot

qt: medialib: do not count on item()

The count is initialized by a call to rowCount(), which must be called
before calling item().

Signed-off-by: Pierre Lamot <[email protected]>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=40cbc29557cfc92f8c6fd1afc21e46228a050a91
---

 modules/gui/qt/medialibrary/mlbasemodel.hpp | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/modules/gui/qt/medialibrary/mlbasemodel.hpp 
b/modules/gui/qt/medialibrary/mlbasemodel.hpp
index 10ce9b71ec..1d2cb2233a 100644
--- a/modules/gui/qt/medialibrary/mlbasemodel.hpp
+++ b/modules/gui/qt/medialibrary/mlbasemodel.hpp
@@ -219,20 +219,11 @@ public:
 protected:
     T* item(int signedidx) const
     {
-        if (signedidx < 0)
+        if (!m_initialized || signedidx < 0)
             return nullptr;
 
         unsigned int idx = static_cast<unsigned int>(signedidx);
-        if ( m_initialized == false )
-        {
-            m_total_count = countTotalElements();
-            if ( m_total_count > 0 )
-                m_item_list = fetch();
-            m_initialized = true;
-            emit countChanged( static_cast<unsigned int>(m_total_count) );
-        }
-
-        if ( idx >= m_total_count  )
+        if ( idx >= m_total_count )
             return nullptr;
 
         if ( idx < m_query_param.i_offset ||  idx >= m_query_param.i_offset + 
m_item_list.size() )

_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to