[vlc-devel] [PATCH 03/13] qt: medialib: do not count on item()
Romain Vimont
rom1v at videolabs.io
Mon Nov 23 17:30:17 CET 2020
The count is initialized by a call to rowCount(), which must be called
before calling item().
---
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() )
--
2.29.2
More information about the vlc-devel
mailing list