diff --git a/src/app/application.cpp b/src/app/application.cpp index 405114555..213fea66a 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -220,7 +220,9 @@ void Application::setMemoryWorkingSetLimit(const int size) return; m_storeMemoryWorkingSetLimit = size; +#ifdef QBT_USES_LIBTORRENT2 applyMemoryWorkingSetLimit(); +#endif } #endif @@ -621,7 +623,7 @@ void Application::processParams(const QStringList ¶ms) int Application::exec(const QStringList ¶ms) { -#ifdef Q_OS_WIN +#if (defined(Q_OS_WIN) && defined(QBT_USES_LIBTORRENT2)) applyMemoryWorkingSetLimit(); #endif @@ -794,7 +796,7 @@ void Application::shutdownCleanup(QSessionManager &manager) } #endif -#ifdef Q_OS_WIN +#if (defined(Q_OS_WIN) && defined(QBT_USES_LIBTORRENT2)) void Application::applyMemoryWorkingSetLimit() { const SIZE_T UNIT_SIZE = 1024 * 1024; // MiB diff --git a/src/app/application.h b/src/app/application.h index 54b35ae81..5c45dd3eb 100644 --- a/src/app/application.h +++ b/src/app/application.h @@ -126,7 +126,7 @@ private slots: #endif private: -#ifdef Q_OS_WIN +#if (defined(Q_OS_WIN) && defined(QBT_USES_LIBTORRENT2)) void applyMemoryWorkingSetLimit(); #endif void initializeTranslation(); diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index cba5e8330..c08f0b393 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -62,9 +62,11 @@ namespace // qBittorrent section QBITTORRENT_HEADER, RESUME_DATA_STORAGE, +#if (defined(Q_OS_WIN) && defined(QBT_USES_LIBTORRENT2)) + MEMORY_WORKING_SET_LIMIT, +#endif #if defined(Q_OS_WIN) OS_MEMORY_PRIORITY, - MEMORY_WORKING_SET_LIMIT, #endif // network interface NETWORK_IFACE, @@ -198,7 +200,9 @@ void AdvancedSettings::saveAdvancedSettings() } session->setOSMemoryPriority(prio); +#ifdef QBT_USES_LIBTORRENT2 static_cast(QCoreApplication::instance())->setMemoryWorkingSetLimit(m_spinBoxMemoryWorkingSetLimit.value()); +#endif #endif // Async IO threads session->setAsyncIOThreads(m_spinBoxAsyncIOThreads.value()); @@ -443,6 +447,7 @@ void AdvancedSettings::loadAdvancedSettings() + ' ' + makeLink("https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-memory_priority_information", "(?)")) , &m_comboBoxOSMemoryPriority); +#ifdef QBT_USES_LIBTORRENT2 m_spinBoxMemoryWorkingSetLimit.setMinimum(1); m_spinBoxMemoryWorkingSetLimit.setMaximum(std::numeric_limits::max()); m_spinBoxMemoryWorkingSetLimit.setSuffix(tr(" MiB")); @@ -451,6 +456,7 @@ void AdvancedSettings::loadAdvancedSettings() addRow(MEMORY_WORKING_SET_LIMIT, (tr("Physical memory (RAM) usage limit") + ' ' + makeLink("https://wikipedia.org/wiki/Working_set", "(?)")) , &m_spinBoxMemoryWorkingSetLimit); +#endif #endif // Async IO threads diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index 217ce48f3..8ef0f43ec 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -82,8 +82,10 @@ private: // OS dependent settings #if defined(Q_OS_WIN) QComboBox m_comboBoxOSMemoryPriority; +#ifdef QBT_USES_LIBTORRENT2 QSpinBox m_spinBoxMemoryWorkingSetLimit; #endif +#endif #ifndef Q_OS_MACOS QCheckBox m_checkBoxIconsInMenusEnabled;