summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Bruckner <max@maxbruckner.de>2023-01-22 23:14:05 +0100
committerMax Bruckner <max@maxbruckner.de>2023-01-25 22:01:58 +0100
commit92a724d95c4e5609936784ef7b2ba812113641d8 (patch)
tree4ca15305a67d80fe39f48c59cfdc3001798313ca /src
parent98e99b0f77451414f2b26f1094de59e28b2f2f91 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp8
1 files changed, 8 insertions, 0 deletions
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 = "";