[vlc-devel] [PATCH] qt: medialib: fix compatibility with Qt < 5.15

Romain Vimont rom1v at videolabs.io
Tue Feb 23 12:23:34 UTC 2021


QThreadPool::start() could only be called with a QRunnable before Qt
5.15, not a lambda: https://doc.qt.io/qt-5/qthreadpool.html#start-1

Use the older method instead.
---
 modules/gui/qt/medialibrary/medialib.cpp | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/modules/gui/qt/medialibrary/medialib.cpp b/modules/gui/qt/medialibrary/medialib.cpp
index bc5878ae0c..ffe5b1b071 100644
--- a/modules/gui/qt/medialibrary/medialib.cpp
+++ b/modules/gui/qt/medialibrary/medialib.cpp
@@ -225,9 +225,18 @@ void MediaLib::insertIntoPlaylist(const size_t index, const QVariantList &itemId
 
 void MediaLib::reload()
 {
-    m_threadPool.start([ml = m_ml] {
-        vlc_ml_reload_folder(ml, nullptr);
-    });
+    /* m_threadPool.start(lambda) is only supported since Qt 5.15 */
+    struct Task : QRunnable {
+        vlc_medialibrary_t *m_ml;
+
+        Task(vlc_medialibrary_t *ml) : m_ml(ml) {}
+        void run() override
+        {
+            vlc_ml_reload_folder(m_ml, nullptr);
+        }
+    };
+
+    m_threadPool.start(new Task(m_ml));
 }
 
 vlc_medialibrary_t* MediaLib::vlcMl()
-- 
2.30.1



More information about the vlc-devel mailing list