[vlc-commits] qt: medialib: do not count on item()
Romain Vimont
git at videolan.org
Wed Dec 2 17:32:16 UTC 2020
vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | 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 <pierre at videolabs.io>
> 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() )
More information about the vlc-commits
mailing list