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 = "";