From 1a0144a08f9ceeb93010f284e52c4178c1de80f9 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Wed, 29 Mar 2023 08:34:57 +0200 Subject: [PATCH] try to fix freezing when updating feeds with new Qt --- .../scripts/github-actions/build-linux-mac.sh | 2 +- .../scripts/github-actions/build-windows.ps1 | 4 ++-- src/librssguard/core/feeddownloader.cpp | 2 +- src/librssguard/core/messageobject.cpp | 2 ++ src/librssguard/miscellaneous/application.cpp | 15 ++++++++++----- src/librssguard/miscellaneous/application.h | 5 ++++- .../standard/standardfeedsimportexportmodel.cpp | 6 +++--- 7 files changed, 23 insertions(+), 13 deletions(-) diff --git a/resources/scripts/github-actions/build-linux-mac.sh b/resources/scripts/github-actions/build-linux-mac.sh index 97e9dd7eb..2daf985c7 100755 --- a/resources/scripts/github-actions/build-linux-mac.sh +++ b/resources/scripts/github-actions/build-linux-mac.sh @@ -51,7 +51,7 @@ else USE_QT6="ON" QTPATH="$(pwd)/Qt" - QTVERSION="6.4.2" + QTVERSION="6.4.3" QTBIN="$QTPATH/$QTVERSION/$QTOS/bin" pip3 install aqtinstall diff --git a/resources/scripts/github-actions/build-windows.ps1 b/resources/scripts/github-actions/build-windows.ps1 index 527930343..dbed002c0 100755 --- a/resources/scripts/github-actions/build-windows.ps1 +++ b/resources/scripts/github-actions/build-windows.ps1 @@ -21,10 +21,10 @@ $ProgressPreference = 'SilentlyContinue' # Get and prepare needed dependencies. if ($use_qt5 -eq "ON") { - $qt_version = "5.15.2" + $qt_version = "5.15.3" } else { - $qt_version = "6.3.1" + $qt_version = "6.4.3" } $maria_version = "10.6.11" diff --git a/src/librssguard/core/feeddownloader.cpp b/src/librssguard/core/feeddownloader.cpp index 11954405d..39a47bb5a 100644 --- a/src/librssguard/core/feeddownloader.cpp +++ b/src/librssguard/core/feeddownloader.cpp @@ -157,7 +157,7 @@ void FeedDownloader::updateFeeds(const QList& feeds) { return updateThreadedFeed(fd); }; - m_watcherLookup.setFuture(QtConcurrent::mapped(m_feeds, func)); + m_watcherLookup.setFuture(QtConcurrent::mapped(qApp->workHorsePool(), m_feeds, func)); } } diff --git a/src/librssguard/core/messageobject.cpp b/src/librssguard/core/messageobject.cpp index c54241e44..540a9e4b3 100644 --- a/src/librssguard/core/messageobject.cpp +++ b/src/librssguard/core/messageobject.cpp @@ -172,6 +172,8 @@ QString MessageObject::createLabelId(const QString& title, const QString& hex_co if (hex_color.isEmpty()) { // Generate color. } + + // TODO: CONTINUE } void MessageObject::addEnclosure(const QString& url, const QString& mime_type) const { diff --git a/src/librssguard/miscellaneous/application.cpp b/src/librssguard/miscellaneous/application.cpp index aad00dabb..5c9fea744 100644 --- a/src/librssguard/miscellaneous/application.cpp +++ b/src/librssguard/miscellaneous/application.cpp @@ -85,6 +85,7 @@ Application::Application(const QString& id, int& argc, char** argv, const QStrin #endif m_nodejs = new NodeJs(m_settings, this); + m_workHorsePool = new QThreadPool(this); m_webFactory = new WebFactory(this); m_system = new SystemFactory(this); m_skins = new SkinFactory(this); @@ -215,7 +216,7 @@ Application::Application(const QString& id, int& argc, char** argv, const QStrin QTimer::singleShot(1000, system(), &SystemFactory::checkForUpdatesOnStartup); - setupGlobalThreadPool(); + setupWorkHorsePool(); qDebugNN << LOGSEC_CORE << "OpenSSL version:" << QUOTE_W_SPACE_DOT(QSslSocket::sslLibraryVersionString()); qDebugNN << LOGSEC_CORE << "OpenSSL supported:" << QUOTE_W_SPACE_DOT(QSslSocket::supportsSsl()); @@ -392,6 +393,10 @@ void Application::displayLogMessageInDialog(const QString& message) { } } +QThreadPool* Application::workHorsePool() const { + return m_workHorsePool; +} + int Application::customAdblockPort() const { return m_customAdblockPort; } @@ -948,20 +953,20 @@ void Application::setupCustomDataFolder(const QString& data_folder) { m_customDataFolder = data_folder; } -void Application::setupGlobalThreadPool() { +void Application::setupWorkHorsePool() { auto ideal_th_count = QThread::idealThreadCount(); int custom_threads = m_cmdParser.value(QSL(CLI_THREADS)).toInt(); if (custom_threads > 0) { - QThreadPool::globalInstance()->setMaxThreadCount((std::min)(MAX_THREADPOOL_THREADS, custom_threads)); + m_workHorsePool->setMaxThreadCount((std::min)(MAX_THREADPOOL_THREADS, custom_threads)); } else if (ideal_th_count > 1) { - QThreadPool::globalInstance()->setMaxThreadCount((std::min)(MAX_THREADPOOL_THREADS, 2 * ideal_th_count)); + m_workHorsePool->setMaxThreadCount((std::min)(MAX_THREADPOOL_THREADS, 2 * ideal_th_count)); } // NOTE: Do not expire threads so that their IDs are not reused. // This fixes cross-thread QSqlDatabase access. - QThreadPool::globalInstance()->setExpiryTimeout(-1); + m_workHorsePool->setExpiryTimeout(-1); } void Application::onAdBlockFailure() { diff --git a/src/librssguard/miscellaneous/application.h b/src/librssguard/miscellaneous/application.h index 2576a63da..43a276d0d 100644 --- a/src/librssguard/miscellaneous/application.h +++ b/src/librssguard/miscellaneous/application.h @@ -181,6 +181,8 @@ class RSSGUARD_DLLSPEC Application : public SingleApplication { int customAdblockPort() const; + QThreadPool* workHorsePool() const; + public slots: // Restarts the application. void restart(); @@ -223,7 +225,7 @@ class RSSGUARD_DLLSPEC Application : public SingleApplication { #endif void setupCustomDataFolder(const QString& data_folder); - void setupGlobalThreadPool(); + void setupWorkHorsePool(); void determineFirstRuns(); void eliminateFirstRuns(); void displayLogMessageInDialog(const QString& message); @@ -263,6 +265,7 @@ class RSSGUARD_DLLSPEC Application : public SingleApplication { DownloadManager* m_downloadManager; NotificationFactory* m_notifications; NodeJs* m_nodejs; + QThreadPool* m_workHorsePool; bool m_shouldRestart; bool m_firstRunEver; bool m_firstRunCurrentVersion; diff --git a/src/librssguard/services/standard/standardfeedsimportexportmodel.cpp b/src/librssguard/services/standard/standardfeedsimportexportmodel.cpp index bb0922efd..6ba872faf 100644 --- a/src/librssguard/services/standard/standardfeedsimportexportmodel.cpp +++ b/src/librssguard/services/standard/standardfeedsimportexportmodel.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include FeedsImportExportModel::FeedsImportExportModel(QObject* parent) : AccountCheckSortedModel(parent), m_mode(Mode::Import), m_newRoot(nullptr) { @@ -380,7 +380,7 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, return produceFeed(lookup); }; - QFuture fut = QtConcurrent::mapped(m_lookup, func); + QFuture fut = QtConcurrent::mapped(qApp->workHorsePool(), m_lookup, func); m_watcherLookup.setFuture(fut); @@ -445,7 +445,7 @@ void FeedsImportExportModel::importAsTxtURLPerLine(const QByteArray& data, return produceFeed(lookup); }; - QFuture fut = QtConcurrent::mapped(m_lookup, func); + QFuture fut = QtConcurrent::mapped(qApp->workHorsePool(), m_lookup, func); m_watcherLookup.setFuture(fut);