Mercurial > minori
diff src/gui/pages/anime_list.cc @ 274:f6a756c19bfb
anime_list.cc: use mutexes so we don't sex the stack
strings.cc: use Qt to convert from HTML to plain text.
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Thu, 18 Apr 2024 17:24:42 -0400 |
parents | f31305b9f60a |
children | 9a88e1725fd2 |
line wrap: on
line diff
--- a/src/gui/pages/anime_list.cc Thu Apr 18 16:53:17 2024 -0400 +++ b/src/gui/pages/anime_list.cc Thu Apr 18 17:24:42 2024 -0400 @@ -38,17 +38,18 @@ } void AnimeListPageUpdateEntryThread::AddToQueue(int id) { - if (isRunning()) - return; /* don't let us fuck ourselves */ - + const std::lock_guard<std::mutex> guard(_queue_mutex); queue_.push(id); } /* processes the queue... */ void AnimeListPageUpdateEntryThread::run() { - while (!queue_.empty() && !isInterruptionRequested()) { - Services::UpdateAnimeEntry(queue_.front()); - queue_.pop(); + { + const std::lock_guard<std::mutex> guard(_queue_mutex); + while (!queue_.empty() && !isInterruptionRequested()) { + Services::UpdateAnimeEntry(queue_.front()); + queue_.pop(); + } } page_->Refresh(); } @@ -241,10 +242,8 @@ void AnimeListPage::UpdateAnime(int id) { /* this ought to just add to the thread's buffer. */ - if (update_entry_thread_.isRunning()) { + if (update_entry_thread_.isRunning()) update_entry_thread_.requestInterruption(); - update_entry_thread_.wait(); - } update_entry_thread_.AddToQueue(id); update_entry_thread_.start();