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

"zhilizhao(赵志立)" quinkblack at foxmail.com
Tue Feb 23 14:07:29 UTC 2021



> On Feb 23, 2021, at 9:44 PM, Romain Vimont <rom1v at videolabs.io> wrote:
> 
> On Tue, Feb 23, 2021 at 08:47:35PM +0800, "zhilizhao(赵志立)" wrote:
>> 
>> 
>>> On Feb 23, 2021, at 8:23 PM, Romain Vimont <rom1v at videolabs.io> wrote:
>>> 
>>> 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);
>>> +        }
>>> +    };
>>> +
>> 
>> From the documentation, I’m not sure whether QRunnable::autoDelete() is enabled by default or not.
>> https://doc.qt.io/qt-5/qrunnable.html#details
> 
> Yes, it is: https://doc.qt.io/qt-5/qrunnable.html#QRunnable

OK, sorry for the noise.

> 
>> Constructs a QRunnable. Auto-deletion is enabled by default.
> 
> Regards
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list