┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
authorElvis Angelaccio <[email protected]>2018-04-05 22:33:34 +0200
committerElvis Angelaccio <[email protected]>2018-04-05 23:15:50 +0200
commit30349ef1bdcae0ed80f47c168d46c15020b927d3 (patch)
treecdd3fdaf1697ef9bf5068c02dec099cada37cc6a /src/views
parent386a862de4e67a44afa74f9ac66fba5c8b7abd38 (diff)
[RenameDialog] Fix crash when renaming single items
Summary: `m_spinBox` is initialized only when renaming multiple items. This commit restores the single-item rename logic which was wrongly removed by commit c5eb4e31161ccf422. BUG: 392743 FIXED-IN: 18.03.90 Test Plan: Disable inline renaming and try to rename single or multiple items (and also to undo the jobs). Subscribers: #dolphin Differential Revision: https://phabricator.kde.org/D11972
Diffstat (limited to 'src/views')
-rw-r--r--src/views/renamedialog.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/views/renamedialog.cpp b/src/views/renamedialog.cpp
index 44c0a5a7b..e49f56e2d 100644
--- a/src/views/renamedialog.cpp
+++ b/src/views/renamedialog.cpp
@@ -155,22 +155,29 @@ void RenameDialog::slotAccepted()
widget = this;
}
+ const QList<QUrl> srcList = m_items.urlList();
+ const QString newName = m_lineEdit->text();
KIO::FileUndoManager::CommandType cmdType;
+ KIO::Job *job = nullptr;
if (m_renameOneItem) {
Q_ASSERT(m_items.count() == 1);
cmdType = KIO::FileUndoManager::Rename;
+ const QUrl oldUrl = m_items.constFirst().url();
+ QUrl newUrl = oldUrl.adjusted(QUrl::RemoveFilename);
+ newUrl.setPath(newUrl.path() + KIO::encodeFileName(newName));
+ m_renamedItems << newUrl;
+ job = KIO::moveAs(oldUrl, newUrl, KIO::HideProgressInfo);
} else {
cmdType = KIO::FileUndoManager::BatchRename;
+ job = KIO::batchRename(srcList, newName, m_spinBox->value(), QLatin1Char('#'));
+ connect(qobject_cast<KIO::BatchRenameJob*>(job), &KIO::BatchRenameJob::fileRenamed, this, &RenameDialog::slotFileRenamed);
}
- const QList<QUrl> srcList = m_items.urlList();
- KIO::BatchRenameJob* job = KIO::batchRename(srcList, m_lineEdit->text(), m_spinBox->value(), QLatin1Char('#'));
KJobWidgets::setWindow(job, widget);
const QUrl parentUrl = srcList.first().adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash);
KIO::FileUndoManager::self()->recordJob(cmdType, srcList, parentUrl, job);
- connect(job, &KIO::BatchRenameJob::fileRenamed, this, &RenameDialog::slotFileRenamed);
- connect(job, &KIO::BatchRenameJob::result, this, &RenameDialog::slotResult);
+ connect(job, &KJob::result, this, &RenameDialog::slotResult);
job->uiDelegate()->setAutoErrorHandlingEnabled(true);