From 18b9de831f48f7e748c97af54c7c965ca98351c0 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Sun, 20 Oct 2013 14:07:24 +0300 Subject: [PATCH] Turn off the scheduler when the user manually changes the rate limits mode. --- src/qtlibtorrent/qbtsession.cpp | 5 ++++- src/statusbar.h | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index da16f9958..263cecbe0 100755 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -356,7 +356,7 @@ void QBtSession::configureSession() { } bd_scheduler->start(); } else { - if (bd_scheduler) delete bd_scheduler; + delete bd_scheduler; } #ifndef DISABLE_GUI // Resolve countries @@ -708,6 +708,9 @@ void QBtSession::useAlternativeSpeedsLimit(bool alternative) { qDebug() << Q_FUNC_INFO << alternative; // Save new state to remember it on startup Preferences pref; + // Stop the scheduler when the user has manually changed the bandwidth mode + if (!pref.isSchedulerEnabled()) + delete bd_scheduler; pref.setAltBandwidthEnabled(alternative); // Apply settings to the bittorrent session int down_limit = alternative ? pref.getAltGlobalDownloadLimit() : pref.getGlobalDownloadLimit(); diff --git a/src/statusbar.h b/src/statusbar.h index 65221b827..784cc7493 100644 --- a/src/statusbar.h +++ b/src/statusbar.h @@ -207,7 +207,12 @@ public slots: } void toggleAlternativeSpeeds() { - QBtSession::instance()->useAlternativeSpeedsLimit(!Preferences().isAltBandwidthEnabled()); + Preferences pref; + if (pref.isSchedulerEnabled()) { + pref.setSchedulerEnabled(false); + m_bar->showMessage(tr("Manual change of rate limits mode. The scheduler is disabled."), 5000); + } + QBtSession::instance()->useAlternativeSpeedsLimit(!pref.isAltBandwidthEnabled()); } void capDownloadSpeed() {