From 3d7bf26f85ba7a16f66d95c356f7a07bf327eae5 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Mon, 27 Sep 2010 17:33:43 +0000 Subject: [PATCH] Fix possible crash when changing the save path in torrent addition dialog --- src/torrentadditiondlg.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/torrentadditiondlg.cpp b/src/torrentadditiondlg.cpp index e400e4998..eada81c6b 100644 --- a/src/torrentadditiondlg.cpp +++ b/src/torrentadditiondlg.cpp @@ -120,9 +120,13 @@ void torrentAdditionDialog::saveSettings() { } void torrentAdditionDialog::renameTorrentNameInModel(QString file_path) { + file_path = file_path.trimmed(); + if(file_path.isEmpty()) return; file_path = file_path.replace("\\", "/"); // Rename in torrent files model too - PropListModel->setData(PropListModel->index(0, 0), file_path.split("/", QString::SkipEmptyParts).last()); + QStringList parts = file_path.split("/", QString::SkipEmptyParts); + if(!parts.empty()) + PropListModel->setData(PropListModel->index(0, 0), parts.last()); } void torrentAdditionDialog::limitDialogWidth() {