set a plugin to be deleted when starting next session

This commit is contained in:
alemuntoni 2021-03-10 13:23:27 +01:00
parent 19a8919e12
commit cd36d7db88
2 changed files with 24 additions and 6 deletions

View File

@ -28,6 +28,7 @@
#include <QPushButton>
#include <QFileDialog>
#include <QMessageBox>
#include <QSettings>
#include <common/plugins/interfaces/filter_plugin.h>
#include <common/plugins/interfaces/iomesh_plugin.h>
@ -91,11 +92,15 @@ void PluginInfoDialog::uninstallPluginPushButtonClicked()
pm.unloadPlugin(fpi);
bool res = QFile::remove(fdel.absoluteFilePath());
if (!res){
QSettings settings;
QStringList toDeletePlugins = settings.value("ToDeletePlugins").value<QStringList>();
toDeletePlugins.append(fdel.absoluteFilePath());
settings.setValue("ToDeletePlugins", toDeletePlugins);
//pm.loadPlugin(fdel.absoluteFilePath());
QMessageBox::warning(
this, "Error while deleting plugin.",
"Impossible to delete the plugin. Please delete manually the following file (or disable the plugin):\n"
+ fdel.absoluteFilePath());
//QMessageBox::warning(
// this, "Error while deleting plugin.",
// "Impossible to delete the plugin. Please delete manually the following file (or disable the plugin):\n"
// + fdel.absoluteFilePath());
}
ui->treeWidget->clear();
populateTreeWidget();

View File

@ -54,6 +54,21 @@ MainWindow::MainWindow():
PM(meshlab::pluginManagerInstance()),
_currviewcontainer(NULL)
{
QSettings settings;
//toDelete plugins, flagged in the last session
//this is needed on windows, since it refuses to delete dll plugins while meshlab is
//running. Therefore, in these cases plugins that are going to be deleted are
//saved in this list, and the files are removed in the next meshlab session,
//BEFORE they will be loaded. Therefore, these lines need to be executed
//before the PM.loadPlugins call.
QStringList toDeletePlugins = settings.value("ToDeletePlugins").value<QStringList>();
if (!toDeletePlugins.isEmpty()){
for (const QString& file : toDeletePlugins){
QFile::remove(file);
}
}
settings.remove("ToDeletePlugins");
setContextMenuPolicy(Qt::NoContextMenu);
//workspace = new QWorkspace(this);
@ -70,7 +85,6 @@ MainWindow::MainWindow():
catch (const MLException& e) {
QMessageBox::warning(this, "Error while loading plugins.", e.what());
}
QSettings settings;
//disable previously disabled plugins
QStringList disabledPlugins = settings.value("DisabledPlugins").value<QStringList>();
@ -78,7 +92,6 @@ MainWindow::MainWindow():
if (disabledPlugins.contains(fp->pluginName()))
PM.disablePlugin(fp);
}
//setCentralWidget(workspace);
setCentralWidget(mdiarea);