# HG changeset patch # User Paper # Date 1716157514 14400 # Node ID 8769c5d50b0627f029618264aa20e98137c5123a # Parent f4538a4c91ba94dddb00ebbedf3ebb68fc9706b6 pages/anime_list: don't call GUI functions in a non-GUI thread diff -r f4538a4c91ba -r 8769c5d50b06 include/gui/pages/anime_list.h --- a/include/gui/pages/anime_list.h Sun May 19 17:48:52 2024 -0400 +++ b/include/gui/pages/anime_list.h Sun May 19 18:25:14 2024 -0400 @@ -15,11 +15,16 @@ class AnimeListPage; class AnimeListPageUpdateEntryThread final : public QThread { + Q_OBJECT + public: AnimeListPageUpdateEntryThread(AnimeListPage* parent); void AddToQueue(int id); +signals: + void NeedRefresh(); + protected: void run() override; @@ -73,13 +78,13 @@ std::vector list; }; -/* todo: rename these to "page" or something more - sensible than "widget" */ class AnimeListPage final : public QWidget { Q_OBJECT public: AnimeListPage(QWidget* parent = nullptr); + +public slots: void Refresh(); protected: diff -r f4538a4c91ba -r 8769c5d50b06 src/gui/pages/anime_list.cc --- a/src/gui/pages/anime_list.cc Sun May 19 17:48:52 2024 -0400 +++ b/src/gui/pages/anime_list.cc Sun May 19 18:25:14 2024 -0400 @@ -51,7 +51,7 @@ queue_.pop(); } } - page_->Refresh(); + emit NeedRefresh(); } AnimeListPageSortFilter::AnimeListPageSortFilter(QObject* parent) : QSortFilterProxyModel(parent) { @@ -512,6 +512,8 @@ tree_view->setModel(sort_models[index]); }); + connect(&update_entry_thread_, &AnimeListPageUpdateEntryThread::NeedRefresh, this, &AnimeListPage::Refresh); + SetColumnDefaults(); setFocusPolicy(Qt::TabFocus); setFocusProxy(tab_bar);