Mercurial > minori
diff src/gui/widgets/poster.cc @ 230:2f5a9247e501
torrents: implement download button
erg
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Sat, 13 Jan 2024 09:42:02 -0500 |
parents | 9613d72b097e |
children | ff0061e75f0f |
line wrap: on
line diff
--- a/src/gui/widgets/poster.cc Wed Jan 10 21:23:57 2024 -0500 +++ b/src/gui/widgets/poster.cc Sat Jan 13 09:42:02 2024 -0500 @@ -12,7 +12,7 @@ #include <QLabel> #include <QMessageBox> #include <QPixmap> -#include <QThreadPool> +#include <QThread> #include <QUrl> #include <curl/curl.h> @@ -35,10 +35,19 @@ } void Poster::SetAnime(const Anime::Anime& anime) { - QThreadPool::globalInstance()->start([this, anime] { - QByteArray ba = HTTP::Get(anime.GetPosterUrl(), {}); - ImageDownloadFinished(ba); - }); + { + QByteArray ba; + + QThread* thread = QThread::create([&] { + ba = HTTP::Get(anime.GetPosterUrl(), {}); + }); + + connect(thread, &QThread::finished, this, [&] { + ImageDownloadFinished(ba); + }); + + thread->start(); + } label->disconnect(); connect(label, &ClickableLabel::clicked, this,