mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-03-09 11:51:03 +00:00
Fix possible crash when using alternative speed limits
This commit is contained in:
parent
de3135c43b
commit
621ec11ae3
@ -653,8 +653,20 @@ void Bittorrent::useAlternativeSpeedsLimit(bool alternative) {
|
||||
s->set_download_rate_limit(Preferences::getAltGlobalDownloadLimit()*1024);
|
||||
s->set_upload_rate_limit(Preferences::getAltGlobalUploadLimit()*1024);
|
||||
} else {
|
||||
s->set_download_rate_limit(Preferences::getGlobalDownloadLimit()*1024);
|
||||
s->set_upload_rate_limit(Preferences::getGlobalUploadLimit()*1024);
|
||||
int down_limit = Preferences::getGlobalDownloadLimit();
|
||||
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);
|
||||
}
|
||||
|
@ -331,7 +331,10 @@ public:
|
||||
|
||||
static int getAltGlobalDownloadLimit() {
|
||||
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) {
|
||||
@ -342,7 +345,10 @@ public:
|
||||
|
||||
static int getAltGlobalUploadLimit() {
|
||||
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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user