Mercurial > minori
diff src/gui/pages/anime_list.cc @ 320:1b5c04268d6a
services/kitsu: ACTUALLY finish GetAnimeList
there are some things the API just... doesn't provide. therefore
we have to request the genres separately any time a new anime info
box is opened...
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 12 Jun 2024 19:49:19 -0400 |
parents | 34347fd2a2de |
children | 5d3c9b31aa6e |
line wrap: on
line diff
--- a/src/gui/pages/anime_list.cc Wed Jun 12 17:52:26 2024 -0400 +++ b/src/gui/pages/anime_list.cc Wed Jun 12 19:49:19 2024 -0400 @@ -33,24 +33,29 @@ #include <set> -AnimeListPageUpdateEntryThread::AnimeListPageUpdateEntryThread(AnimeListPage* parent) : QThread(parent) { - page_ = parent; -} +AnimeListPageUpdateEntryThread::AnimeListPageUpdateEntryThread(QObject* parent) : QThread(parent) {} void AnimeListPageUpdateEntryThread::AddToQueue(int id) { - const std::lock_guard<std::mutex> guard(_queue_mutex); + const std::lock_guard<std::mutex> guard(queue_mutex_); queue_.push(id); } /* processes the queue... */ void AnimeListPageUpdateEntryThread::run() { - { - const std::lock_guard<std::mutex> guard(_queue_mutex); - while (!queue_.empty() && !isInterruptionRequested()) { - Services::UpdateAnimeEntry(queue_.front()); - queue_.pop(); - } + queue_mutex_.lock(); + while (!queue_.empty() && !isInterruptionRequested()) { + int id = queue_.front(); + + /* unlock the mutex for a long blocking operation, so items + * can be added without worry */ + queue_mutex_.unlock(); + Services::UpdateAnimeEntry(id); + queue_mutex_.lock(); + + queue_.pop(); } + queue_mutex_.unlock(); + emit NeedRefresh(); } @@ -447,7 +452,7 @@ /* --------- QTabWidget replication end ---------- */ -AnimeListPage::AnimeListPage(QWidget* parent) : QWidget(parent), update_entry_thread_(this) { +AnimeListPage::AnimeListPage(QWidget* parent) : QWidget(parent) { /* Tab bar */ tab_bar = new QTabBar(this); tab_bar->setExpanding(false);