Fix possible crash when using alternative speed limits

This commit is contained in:
Christophe Dumez
2010-06-24 21:36:05 +00:00
parent dd14f5ab39
commit 02d672540e
3 changed files with 23 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
* Unreleased - Christophe Dumez <chris@qbittorrent.org> - v2.2.11 * Unreleased - Christophe Dumez <chris@qbittorrent.org> - v2.2.11
- BUGFIX: Fix parsing of program arguments with spaces - BUGFIX: Fix parsing of program arguments with spaces
- BUGFIX: Fix possible crashing when using alternative speed limits (#598272)
* Wed Jun 23 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.2.10 * Wed Jun 23 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.2.10
- BUGFIX: Fix Web UI in qBittorrent nox version - BUGFIX: Fix Web UI in qBittorrent nox version

View File

@@ -637,8 +637,20 @@ void Bittorrent::useAlternativeSpeedsLimit(bool alternative) {
s->set_download_rate_limit(Preferences::getAltGlobalDownloadLimit()*1024); s->set_download_rate_limit(Preferences::getAltGlobalDownloadLimit()*1024);
s->set_upload_rate_limit(Preferences::getAltGlobalUploadLimit()*1024); s->set_upload_rate_limit(Preferences::getAltGlobalUploadLimit()*1024);
} else { } else {
s->set_download_rate_limit(Preferences::getGlobalDownloadLimit()*1024); int down_limit = Preferences::getGlobalDownloadLimit();
s->set_upload_rate_limit(Preferences::getGlobalUploadLimit()*1024); if(down_limit <= 0) {
down_limit = -1;
} else {
down_limit *= 1024;
}
s->set_download_rate_limit(down_limit);
int up_limit = Preferences::getGlobalUploadLimit();
if(up_limit <= 0) {
up_limit = -1;
} else {
up_limit *= 1024;
}
s->set_upload_rate_limit(up_limit);
} }
emit alternativeSpeedsModeChanged(alternative); emit alternativeSpeedsModeChanged(alternative);
} }

View File

@@ -310,7 +310,10 @@ public:
static int getAltGlobalDownloadLimit() { static int getAltGlobalDownloadLimit() {
QSettings settings("qBittorrent", "qBittorrent"); QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Connection/GlobalDLLimitAlt"), 10).toInt(); int ret = settings.value(QString::fromUtf8("Preferences/Connection/GlobalDLLimitAlt"), 10).toInt();
if(ret <= 0)
ret = 10;
return ret;
} }
static void setAltGlobalDownloadLimit(int limit) { static void setAltGlobalDownloadLimit(int limit) {
@@ -321,7 +324,10 @@ public:
static int getAltGlobalUploadLimit() { static int getAltGlobalUploadLimit() {
QSettings settings("qBittorrent", "qBittorrent"); QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Connection/GlobalUPLimitAlt"), 10).toInt(); int ret = settings.value(QString::fromUtf8("Preferences/Connection/GlobalUPLimitAlt"), 10).toInt();
if(ret <= 0)
ret = 10;
return ret;
} }
static void setAltGlobalUploadLimit(int limit) { static void setAltGlobalUploadLimit(int limit) {