Avoid using exceptions.

This commit is contained in:
Teo Mrnjavac 2016-04-20 14:44:55 +02:00
parent cf4d687d54
commit 1b958db71f
1 changed files with 14 additions and 13 deletions

View File

@ -457,21 +457,22 @@ void MainWindow::enableActions()
part->fileSystem().unmountTitle() :
part->fileSystem().mountTitle());
try {
if (part && part->roles().has(PartitionRole::Luks)) {
const FileSystem& fsRef = part->fileSystem();
const FS::luks* luksFs = dynamic_cast<const FS::luks*>(&fsRef);
actionCollection()->action(QStringLiteral("decryptPartition"))
->setEnabled(part &&
(part->roles().has(PartitionRole::Luks)) &&
(dynamic_cast<const FS::luks&>(part->fileSystem()).canCryptOpen(part->partitionPath()) ||
dynamic_cast<const FS::luks&>(part->fileSystem()).canCryptClose(part->partitionPath())));
if (part && part->roles().has(PartitionRole::Luks))
{
const FS::luks& luksFs = dynamic_cast<const FS::luks&>(part->fileSystem());
actionCollection()->action(QStringLiteral("decryptPartition"))
->setText(luksFs.isCryptOpen() ?
luksFs.cryptCloseTitle() :
luksFs.cryptOpenTitle());
->setEnabled(luksFs &&
(luksFs->canCryptOpen(part->partitionPath()) ||
luksFs->canCryptClose(part->partitionPath())));
if (luksFs) {
actionCollection()->action(QStringLiteral("decryptPartition"))
->setText(luksFs->isCryptOpen() ?
luksFs->cryptCloseTitle() :
luksFs->cryptOpenTitle());
}
} catch (const std::bad_cast&) {
}
else {
actionCollection()->action(QStringLiteral("decryptPartition"))
->setEnabled(false);
}