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

Romain Vimont rom1v at videolabs.io
Tue Feb 23 13:44:22 UTC 2021


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

> Constructs a QRunnable. Auto-deletion is enabled by default.

Regards


More information about the vlc-devel mailing list