[vlc-devel] [PATCH 2/2] qt: medialib: set cover field from the UI thread
Romain Vimont
rom1v at videolabs.io
Mon Nov 9 17:33:58 CET 2020
The m_cover field is exposed (via getCover()) as a QML property, so it
must always be changed from the UI thread.
---
modules/gui/qt/medialibrary/mlgenre.cpp | 5 +++--
modules/gui/qt/medialibrary/mlgenre.hpp | 4 +++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/modules/gui/qt/medialibrary/mlgenre.cpp b/modules/gui/qt/medialibrary/mlgenre.cpp
index d2f13f37f7..b4e8aa3eb5 100644
--- a/modules/gui/qt/medialibrary/mlgenre.cpp
+++ b/modules/gui/qt/medialibrary/mlgenre.cpp
@@ -173,7 +173,7 @@ public:
painter.end();
if (image.save(m_filepath, "jpg"))
- m_genre->setCover(QUrl::fromLocalFile(m_filepath).toString());
+ emit m_genre->coverAvailable(QUrl::fromLocalFile(m_filepath).toString());
{
QMutexLocker lock(&m_taskLock);
@@ -215,6 +215,7 @@ MLGenre::MLGenre(vlc_medialibrary_t* ml, const vlc_ml_genre_t *_data, QObject *_
{
assert(_data);
connect(this, &MLGenre::askGenerateCover, this, &MLGenre::generateThumbnail);
+ connect(this, &MLGenre::coverAvailable, this, &MLGenre::setCover);
}
MLGenre::MLGenre(const MLGenre &genre, QObject *_parent)
@@ -263,7 +264,7 @@ QString MLGenre::getCover() const
return m_cover;
}
-void MLGenre::setCover(const QString cover)
+void MLGenre::setCover(const QString &cover)
{
m_cover = cover;
//TODO store in media library
diff --git a/modules/gui/qt/medialibrary/mlgenre.hpp b/modules/gui/qt/medialibrary/mlgenre.hpp
index 66b5773be4..b7a288c287 100644
--- a/modules/gui/qt/medialibrary/mlgenre.hpp
+++ b/modules/gui/qt/medialibrary/mlgenre.hpp
@@ -57,8 +57,10 @@ signals:
void coverChanged( const QString );
void askGenerateCover( QPrivateSignal ) const;
+ void coverAvailable(const QString &QString);
+
public slots:
- void setCover(const QString cover);
+ void setCover(const QString &cover);
private slots:
void generateThumbnail();
--
2.29.2
More information about the vlc-devel
mailing list