[vlc-commits] [Git][videolan/vlc][master] qt: request model reset on MLItem update

Steve Lhomme (@robUx4) gitlab at videolan.org
Sat Oct 5 15:54:56 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
02b19717 by Pierre Lamot at 2024-10-05T15:41:09+00:00
qt: request model reset on MLItem update

we can't know if after the change the item should become/remain visible. This is
especially problematic if user interaction would change the visibility of an
item in a view. For instance setting isFavorite to false in a view showing
favorite only.

- - - - -


1 changed file:

- modules/gui/qt/medialibrary/mlbasemodel.cpp


Changes:

=====================================
modules/gui/qt/medialibrary/mlbasemodel.cpp
=====================================
@@ -378,24 +378,14 @@ MLItem *MLBaseModel::findInCache(const MLItemId& id, int *index) const
     return item ? item->get() : nullptr;
 }
 
-void MLBaseModel::updateItemInCache(const MLItemId& mlid)
+void MLBaseModel::updateItemInCache(const MLItemId&)
 {
     Q_D(MLBaseModel);
-    if (!d->m_cache)
-    {
-        emit resetRequested();
-        return;
-    }
-    MLItem* item = findInCache(mlid, nullptr);
-    if (!item) // items isn't loaded
-        return;
-
-    if (!m_itemLoader)
-        m_itemLoader = createMLLoader();
-    m_itemLoader->loadItemByIdTask(mlid,
-        [d](qint64, std::unique_ptr<MLItem>&& item) {
-            d->m_cache->updateItem(std::move(item));
-    });
+    // we can't safely update the item in the cache because our view may have a filter
+    // and the update may cause the item filtered state to change requiring it to enter/leave
+    // the cache
+    emit resetRequested();
+    return;
 }
 
 void MLBaseModel::deleteItemInCache(const MLItemId& mlid)



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/02b197170de07c75a70fa5b414d213ba57b46f56

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/02b197170de07c75a70fa5b414d213ba57b46f56
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list