Commit 2af8d35e authored by Elvis Angelaccio's avatar Elvis Angelaccio

Stop crashing when all read-write plugins are disabled

CreateDialog assumes that `m_supportedMimeTypes` is never empty, it will crash otherwise.

If that's the case (i.e. when all the read-write plugins have been disabled),
we just disable the Compress menu item and the New action (as the
CreateDialog would just be useless).

For the New action, we also need to check whether the settings have been
changed and update its enabled status accordingly.

BUG: 390690
FIXED-IN: 17.12.3
parent cec095d6
......@@ -75,11 +75,7 @@ QList<QAction*> CompressFileItemAction::actions(const KFileItemListProperties& f
QAction *compressMenuAction = new QAction(i18nc("@action:inmenu Compress submenu in Dolphin context menu", "Compress"), parentWidget);
compressMenuAction->setMenu(compressMenu);
// #189177: disable compress menu in read-only folders.
if (!fileItemInfos.supportsWriting()) {
compressMenuAction->setEnabled(false);
}
compressMenuAction->setEnabled(fileItemInfos.supportsWriting() && !m_pluginManager->availableWritePlugins().isEmpty());
actions << compressMenuAction;
return actions;
......
......@@ -167,6 +167,8 @@ bool MainWindow::loadPart()
connect(m_part, SIGNAL(busy()), this, SLOT(updateActions()), Qt::QueuedConnection);
connect(m_part, QOverload<>::of(&KParts::ReadOnlyPart::completed), this, &MainWindow::addPartUrl);
updateActions();
return true;
}
......@@ -193,7 +195,8 @@ void MainWindow::setupActions()
void MainWindow::updateActions()
{
Interface *iface = qobject_cast<Interface*>(m_part);
m_newAction->setEnabled(!iface->isBusy());
Kerfuffle::PluginManager pluginManager;
m_newAction->setEnabled(!iface->isBusy() && !pluginManager.availableWritePlugins().isEmpty());
m_openAction->setEnabled(!iface->isBusy());
m_recentFilesAction->setEnabled(!iface->isBusy());
}
......@@ -278,6 +281,7 @@ void MainWindow::showSettings()
dialog->setModal(true);
connect(dialog, &KConfigDialog::settingsChanged, this, &MainWindow::writeSettings);
connect(dialog, &KConfigDialog::settingsChanged, this, &MainWindow::updateActions);
dialog->show();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment