From d4b5f6829551d7912e0f03ac93328c647813a621 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Thu, 24 Feb 2011 17:29:47 +0000 Subject: [PATCH] Fix crash when adding an ampty tracker URL --- Changelog | 1 + src/properties/trackerlist.cpp | 1 + src/properties/trackersadditiondlg.h | 9 ++++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index c3f547ebf..e8ef28723 100644 --- a/Changelog +++ b/Changelog @@ -4,6 +4,7 @@ - BUGFIX: Disable OS cache for aligned files to reduce memory consumption - BUGFIX: Fix torrent upload from Web UI (Windows) - BUGFIX: Fix cursor problem in torrent addition dialog + - BUGFIX: Fix crash when additing an empty tracker URL * Tue Feb 8 2011 - Christophe Dumez - v2.6.6 - FEATURE: IP address reported to trackers is now customizable diff --git a/src/properties/trackerlist.cpp b/src/properties/trackerlist.cpp index cf240348f..afbf27064 100644 --- a/src/properties/trackerlist.cpp +++ b/src/properties/trackerlist.cpp @@ -295,6 +295,7 @@ void TrackerList::askForTrackers(){ QStringList trackers = TrackersAdditionDlg::askForTrackers(h); if(!trackers.empty()) { foreach(const QString& tracker, trackers) { + if(tracker.trimmed().isEmpty()) continue; announce_entry url(tracker.toStdString()); url.tier = 0; h.add_tracker(url); diff --git a/src/properties/trackersadditiondlg.h b/src/properties/trackersadditiondlg.h index f66bcbdc2..cc3490a18 100644 --- a/src/properties/trackersadditiondlg.h +++ b/src/properties/trackersadditiondlg.h @@ -67,6 +67,7 @@ public: public slots: void on_uTorrentListButton_clicked() { downloadThread *d = new downloadThread(this); + uTorrentListButton->setEnabled(false); connect(d, SIGNAL(downloadFinished(QString,QString)), SLOT(parseUTorrentList(QString,QString))); connect(d, SIGNAL(downloadFailure(QString,QString)), SLOT(getTrackerError(QString,QString))); //Just to show that it takes times @@ -79,6 +80,8 @@ public slots: if (!list_file.open(QFile::ReadOnly)) { QMessageBox::warning(this, tr("I/O Error"), tr("Error while trying to open the downloaded file."), QMessageBox::Ok); setCursor(Qt::ArrowCursor); + uTorrentListButton->setEnabled(true); + sender()->deleteLater(); return; } QList existingTrackers; @@ -114,16 +117,20 @@ public slots: list_file.remove(); //To restore the cursor ... setCursor(Qt::ArrowCursor); + uTorrentListButton->setEnabled(true); // Display information message if necessary if(nb == 0) { QMessageBox::information(this, tr("No change"), tr("No additional trackers were found."), QMessageBox::Ok); } + sender()->deleteLater(); } - void getTrackerError(QString, QString error) { + void getTrackerError(const QString&, const QString &error) { //To restore the cursor ... setCursor(Qt::ArrowCursor); + uTorrentListButton->setEnabled(true); QMessageBox::warning(this, tr("Download error"), tr("The trackers list could not be downloaded, reason: %1").arg(error), QMessageBox::Ok); + sender()->deleteLater(); } public: