From 92a724d95c4e5609936784ef7b2ba812113641d8 Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Sun, 22 Jan 2023 23:14:05 +0100 Subject: Fix accidental deletion of entire passwordstore This happens if you manage to trigger the deletion path while no directory or password is selected in the tree view. --- src/mainwindow.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d792c6ed..7e1080a5 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -621,6 +621,14 @@ void MainWindow::addPassword() { * sure. */ void MainWindow::onDelete() { + QModelIndex currentIndex = ui->treeView->currentIndex(); + if (!currentIndex.isValid()) { + // This fixes https://github.com/IJHack/QtPass/issues/556 + // Otherwise the entire password directory would be deleted if + // nothing is selected in the tree view. + return; + } + QFileInfo fileOrFolder = model.fileInfo(proxyModel.mapToSource(ui->treeView->currentIndex())); QString file = ""; -- cgit v1.2.3