[vlc-commits] qt: medialib: set cover field from the UI thread

Romain Vimont git at videolan.org
Thu Nov 12 15:48:11 CET 2020


vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Mon Nov  9 17:28:01 2020 +0100| [79173ad9357556a3b7c1d84ae33b4ecf84f30c68] | committer: Alexandre Janniaux

qt: medialib: set cover field from the UI thread

The m_cover field is exposed (via getCover()) as a QML property, so it
must always be changed from the UI thread.

Signed-off-by: Alexandre Janniaux <ajanni at videolabs.io>

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

 modules/gui/qt/medialibrary/mlgenre.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/modules/gui/qt/medialibrary/mlgenre.cpp b/modules/gui/qt/medialibrary/mlgenre.cpp
index d2f13f37f7..fcdc1651f8 100644
--- a/modules/gui/qt/medialibrary/mlgenre.cpp
+++ b/modules/gui/qt/medialibrary/mlgenre.cpp
@@ -173,7 +173,11 @@ public:
         painter.end();
 
         if (image.save(m_filepath, "jpg"))
-            m_genre->setCover(QUrl::fromLocalFile(m_filepath).toString());
+            /* Set the cover from the main thread */
+            QMetaObject::invokeMethod(m_genre, [genre = m_genre, cover = QUrl::fromLocalFile(m_filepath).toString()]
+                {
+                    genre->setCover(std::move(cover));
+                });
 
         {
             QMutexLocker lock(&m_taskLock);



More information about the vlc-commits mailing list