vlc | branch: master | Romain Vimont <[email protected]> | Mon Nov 9 10:58:15 2020 +0100| [598094819aae0bb1097a6c64338ac411bd737157] | committer: Alexandre Janniaux
qt: medialib: remove synchronization Now that the UI state is always accessed from the UI thread, locks and atomics are not necessary anymore. Signed-off-by: Alexandre Janniaux <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=598094819aae0bb1097a6c64338ac411bd737157 --- modules/gui/qt/medialibrary/mlbasemodel.cpp | 1 - modules/gui/qt/medialibrary/mlbasemodel.hpp | 36 +++++++++-------------------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/modules/gui/qt/medialibrary/mlbasemodel.cpp b/modules/gui/qt/medialibrary/mlbasemodel.cpp index 9805e9e86b..f7f2e127e6 100644 --- a/modules/gui/qt/medialibrary/mlbasemodel.cpp +++ b/modules/gui/qt/medialibrary/mlbasemodel.cpp @@ -31,7 +31,6 @@ MLBaseModel::MLBaseModel(QObject *parent) }) , m_need_reset( false ) { - vlc_mutex_init( &m_item_lock ); memset(&m_query_param, 0, sizeof(vlc_ml_query_params_t)); m_query_param.b_desc = false; m_query_param.i_nbResults = 20; //FIXME: value for test diff --git a/modules/gui/qt/medialibrary/mlbasemodel.hpp b/modules/gui/qt/medialibrary/mlbasemodel.hpp index e52e7506c6..c25fb948b3 100644 --- a/modules/gui/qt/medialibrary/mlbasemodel.hpp +++ b/modules/gui/qt/medialibrary/mlbasemodel.hpp @@ -114,11 +114,9 @@ protected: std::unique_ptr<char, void(*)(void*)> m_search_pattern_cstr; QString m_search_pattern; - mutable vlc_mutex_t m_item_lock; - std::unique_ptr<vlc_ml_event_callback_t, std::function<void(vlc_ml_event_callback_t*)>> m_ml_event_handle; - std::atomic_bool m_need_reset; + bool m_need_reset; }; /** @@ -144,26 +142,21 @@ public: int rowCount(const QModelIndex &parent = {}) const override { - bool countHasChanged = false; if (parent.isValid()) return 0; + + if ( m_initialized == false ) { - vlc_mutex_locker lock( &m_item_lock ); - if ( m_initialized == false ) - { - m_total_count = countTotalElements(); - m_initialized = true; - countHasChanged = true; - } - } - if (countHasChanged) + m_total_count = countTotalElements(); + m_initialized = true; emit countChanged( static_cast<unsigned int>(m_total_count) ); + } + return m_total_count; } virtual T* get(int idx) const { - vlc_mutex_locker lock( &m_item_lock ); T* obj = item( idx ); if (!obj) return nullptr; @@ -172,20 +165,16 @@ public: void clear() override { - { - vlc_mutex_locker lock( &m_item_lock ); - m_query_param.i_offset = 0; - m_initialized = false; - m_total_count = 0; - m_item_list.clear(); - } + m_query_param.i_offset = 0; + m_initialized = false; + m_total_count = 0; + m_item_list.clear(); emit countChanged( static_cast<unsigned int>(m_total_count) ); } virtual QVariant getIdForIndex( QVariant index ) const override { - vlc_mutex_locker lock( &m_item_lock ); T* obj = nullptr; if (index.canConvert<int>()) obj = item( index.toInt() ); @@ -202,7 +191,6 @@ public: { QVariantList idList; idList.reserve(indexes.length()); - vlc_mutex_locker lock( &m_item_lock ); std::transform( indexes.begin(), indexes.end(),std::back_inserter(idList), [this](const QModelIndex& index) -> QVariant { T* obj = item( index.row() ); if (!obj) @@ -217,7 +205,6 @@ public: QVariantList idList; idList.reserve(indexes.length()); - vlc_mutex_locker lock( &m_item_lock ); std::transform( indexes.begin(), indexes.end(),std::back_inserter(idList), [this](const QVariant& index) -> QVariant { T* obj = nullptr; if (index.canConvert<int>()) @@ -244,7 +231,6 @@ protected: return nullptr; unsigned int idx = static_cast<unsigned int>(signedidx); - // Must be called in a locked context if ( m_initialized == false ) { m_total_count = countTotalElements(); _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
