From cd36d7db8808a358aa8d2ba20b2b9ff9d80b3968 Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Wed, 10 Mar 2021 13:23:27 +0100 Subject: [PATCH] set a plugin to be deleted when starting next session --- src/meshlab/dialogs/plugin_info_dialog.cpp | 13 +++++++++---- src/meshlab/mainwindow_Init.cpp | 17 +++++++++++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/meshlab/dialogs/plugin_info_dialog.cpp b/src/meshlab/dialogs/plugin_info_dialog.cpp index 221ce5cc5..b0fb15351 100644 --- a/src/meshlab/dialogs/plugin_info_dialog.cpp +++ b/src/meshlab/dialogs/plugin_info_dialog.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -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(); + 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(); diff --git a/src/meshlab/mainwindow_Init.cpp b/src/meshlab/mainwindow_Init.cpp index f30551bc5..db583c28d 100644 --- a/src/meshlab/mainwindow_Init.cpp +++ b/src/meshlab/mainwindow_Init.cpp @@ -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(); + 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(); @@ -78,7 +92,6 @@ MainWindow::MainWindow(): if (disabledPlugins.contains(fp->pluginName())) PM.disablePlugin(fp); } - //setCentralWidget(workspace); setCentralWidget(mdiarea);