diff --git a/src/gui/partitionmanagerwidget.cpp b/src/gui/partitionmanagerwidget.cpp index 14d5287..657bbe9 100644 --- a/src/gui/partitionmanagerwidget.cpp +++ b/src/gui/partitionmanagerwidget.cpp @@ -65,6 +65,8 @@ #include +#include + class PartitionTreeWidgetItem : public QTreeWidgetItem { Q_DISABLE_COPY(PartitionTreeWidgetItem) @@ -420,19 +422,23 @@ void PartitionManagerWidget::onDecryptPartition() return; } - if (p->fileSystem().type() != FileSystem::Luks) + if (!p->roles().has(PartitionRole::Luks)) return; - FS::luks& luksFs = dynamic_cast(p->fileSystem()); + try { + FS::luks& luksFs = dynamic_cast(p->fileSystem()); - if (luksFs.canCryptOpen(p->partitionPath())) { - if (!luksFs.cryptOpen(p->partitionPath())) - KMessageBox::detailedSorry(this, xi18nc("@info", "The encrypted file system on partition %1 could not be unlocked.", p->deviceNode()), QString(), i18nc("@title:window", "Could Not Unlock Encrypted File System.")); - } else if (luksFs.canCryptClose(p->partitionPath())) { - if (!luksFs.cryptClose(p->partitionPath())) - KMessageBox::detailedSorry(this, xi18nc("@info", "The encrypted file system on partition %1 could not be locked.", p->deviceNode()), QString(), i18nc("@title:window", "Could Not Lock Encrypted File System.")); + if (luksFs.canCryptOpen(p->partitionPath())) { + if (!luksFs.cryptOpen(p->partitionPath())) + KMessageBox::detailedSorry(this, xi18nc("@info", "The encrypted file system on partition %1 could not be unlocked.", p->deviceNode()), QString(), i18nc("@title:window", "Could Not Unlock Encrypted File System.")); + } else if (luksFs.canCryptClose(p->partitionPath())) { + if (!luksFs.cryptClose(p->partitionPath())) + KMessageBox::detailedSorry(this, xi18nc("@info", "The encrypted file system on partition %1 could not be locked.", p->deviceNode()), QString(), i18nc("@title:window", "Could Not Lock Encrypted File System.")); + } + } catch (const std::bad_cast&) + { + return; } - updatePartitions(); }