From 042cd4267f55c24a786834ee137ee7d1f3520180 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 19 Jun 2019 22:01:25 +0800 Subject: [PATCH 1/3] Remove upper limit of "Disk cache" setting --- src/base/bittorrent/session.cpp | 9 +++------ src/gui/advancedsettings.cpp | 3 +-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 01ea6c4eb..146669d52 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -2840,22 +2840,19 @@ void Session::setCheckingMemUsage(int size) int Session::diskCacheSize() const { - int size = m_diskCacheSize; - // These macros may not be available on compilers other than MSVC and GCC #ifdef QBT_APP_64BIT - size = qMin(size, 4096); // 4GiB + return qMin(m_diskCacheSize.value(), 33554431); // 32768GiB #else // When build as 32bit binary, set the maximum at less than 2GB to prevent crashes // allocate 1536MiB and leave 512MiB to the rest of program data in RAM - size = qMin(size, 1536); + return qMin(m_diskCacheSize.value(), 1536); #endif - return size; } void Session::setDiskCacheSize(int size) { #ifdef QBT_APP_64BIT - size = qMin(size, 4096); // 4GiB + size = qMin(size, 33554431); // 32768GiB #else // allocate 1536MiB and leave 512MiB to the rest of program data in RAM size = qMin(size, 1536); diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index 5def580b7..cb1a2e27c 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -342,9 +342,8 @@ void AdvancedSettings::loadAdvancedSettings() // Disk write cache spinBoxCache.setMinimum(-1); // When build as 32bit binary, set the maximum at less than 2GB to prevent crashes. - // These macros may not be available on compilers other than MSVC and GCC #ifdef QBT_APP_64BIT - spinBoxCache.setMaximum(4096); + spinBoxCache.setMaximum(33554431); // 32768GiB #else // allocate 1536MiB and leave 512MiB to the rest of program data in RAM spinBoxCache.setMaximum(1536); From 75c80c371658f3d128cdf913336cb85d36e7faf0 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 19 Jun 2019 22:15:58 +0800 Subject: [PATCH 2/3] Remove limits of "Disk cache expiry interval" setting --- src/gui/advancedsettings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index cb1a2e27c..e3cddc567 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -353,8 +353,8 @@ void AdvancedSettings::loadAdvancedSettings() addRow(DISK_CACHE, (tr("Disk cache") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#cache_size", "(?)")) , &spinBoxCache); // Disk cache expiry - spinBoxCacheTTL.setMinimum(15); - spinBoxCacheTTL.setMaximum(600); + spinBoxCacheTTL.setMinimum(1); + spinBoxCacheTTL.setMaximum(std::numeric_limits::max()); spinBoxCacheTTL.setValue(session->diskCacheTTL()); spinBoxCacheTTL.setSuffix(tr(" s", " seconds")); addRow(DISK_CACHE_TTL, (tr("Disk cache expiry interval") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#cache_expiry", "(?)")) From 0b1b3c1f8427ccc0616ff0091a14cd550957273a Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 19 Jun 2019 22:23:58 +0800 Subject: [PATCH 3/3] Use numeric_limits instead of constants from C In C++, using numeric_limits is more idiomatic compared to using constants. --- src/base/utils/random.cpp | 1 - src/base/utils/random.h | 3 ++- src/gui/advancedsettings.cpp | 6 +++--- src/webui/api/searchcontroller.cpp | 4 +++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/base/utils/random.cpp b/src/base/utils/random.cpp index ef46fe860..b0b1e2d96 100644 --- a/src/base/utils/random.cpp +++ b/src/base/utils/random.cpp @@ -28,7 +28,6 @@ #include "random.h" -#include #include #include diff --git a/src/base/utils/random.h b/src/base/utils/random.h index 93448191a..cc1a2888e 100644 --- a/src/base/utils/random.h +++ b/src/base/utils/random.h @@ -30,12 +30,13 @@ #define UTILS_RANDOM_H #include +#include namespace Utils { namespace Random { - uint32_t rand(uint32_t min = 0, uint32_t max = UINT32_MAX); + uint32_t rand(uint32_t min = 0, uint32_t max = std::numeric_limits::max()); } } diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index e3cddc567..60b045474 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -377,19 +377,19 @@ void AdvancedSettings::loadAdvancedSettings() , &checkBoxSuggestMode); // Send buffer watermark spinBoxSendBufferWatermark.setMinimum(1); - spinBoxSendBufferWatermark.setMaximum(INT_MAX); + spinBoxSendBufferWatermark.setMaximum(std::numeric_limits::max()); spinBoxSendBufferWatermark.setSuffix(tr(" KiB")); spinBoxSendBufferWatermark.setValue(session->sendBufferWatermark()); addRow(SEND_BUF_WATERMARK, (tr("Send buffer watermark") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#send_buffer_watermark", "(?)")) , &spinBoxSendBufferWatermark); spinBoxSendBufferLowWatermark.setMinimum(1); - spinBoxSendBufferLowWatermark.setMaximum(INT_MAX); + spinBoxSendBufferLowWatermark.setMaximum(std::numeric_limits::max()); spinBoxSendBufferLowWatermark.setSuffix(tr(" KiB")); spinBoxSendBufferLowWatermark.setValue(session->sendBufferLowWatermark()); addRow(SEND_BUF_LOW_WATERMARK, (tr("Send buffer low watermark") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#send_buffer_low_watermark", "(?)")) , &spinBoxSendBufferLowWatermark); spinBoxSendBufferWatermarkFactor.setMinimum(1); - spinBoxSendBufferWatermarkFactor.setMaximum(INT_MAX); + spinBoxSendBufferWatermarkFactor.setMaximum(std::numeric_limits::max()); spinBoxSendBufferWatermarkFactor.setSuffix(" %"); spinBoxSendBufferWatermarkFactor.setValue(session->sendBufferWatermarkFactor()); addRow(SEND_BUF_WATERMARK_FACTOR, (tr("Send buffer watermark factor") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#send_buffer_watermark_factor", "(?)")) diff --git a/src/webui/api/searchcontroller.cpp b/src/webui/api/searchcontroller.cpp index 37491b4cd..1523cece5 100644 --- a/src/webui/api/searchcontroller.cpp +++ b/src/webui/api/searchcontroller.cpp @@ -28,6 +28,8 @@ #include "searchcontroller.h" +#include + #include #include #include @@ -293,7 +295,7 @@ int SearchController::generateSearchId() const while (true) { - const auto id = Utils::Random::rand(1, INT_MAX); + const int id = Utils::Random::rand(1, std::numeric_limits::max()); if (!searchHandlers.contains(id)) return id; }