summaryrefslogtreecommitdiff
path: root/src/plugincontainer.cpp
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2020-11-09 04:27:12 -0500
committerGitHub <noreply@github.com>2020-11-09 04:27:12 -0500
commit84e53f3ab3cd2b89eed3e37be734da3e997f4032 (patch)
tree2b14f10377b1ca2b85317c62267a6cf74c64d102 /src/plugincontainer.cpp
parentd23b38b4dfbc61ffe509dd2627ecbf3589409409 (diff)
parentefdda8e7385446096a1032c2b7c2aeaf57132c78 (diff)
Merge pull request #1284 from isanae/command-line-cleanup
Command line cleanup
Diffstat (limited to 'src/plugincontainer.cpp')
-rw-r--r--src/plugincontainer.cpp73
1 files changed, 64 insertions, 9 deletions
diff --git a/src/plugincontainer.cpp b/src/plugincontainer.cpp
index 908677c2..dd4ccbb1 100644
--- a/src/plugincontainer.cpp
+++ b/src/plugincontainer.cpp
@@ -405,22 +405,58 @@ void PluginContainer::loadPlugins()
}
QFile loadCheck;
+ QString skipPlugin;
if (m_Organizer) {
loadCheck.setFileName(qApp->property("dataPath").toString() + "/plugin_loadcheck.tmp");
+
if (loadCheck.exists() && loadCheck.open(QIODevice::ReadOnly)) {
// oh, there was a failed plugin load last time. Find out which plugin was loaded last
QString fileName;
while (!loadCheck.atEnd()) {
fileName = QString::fromUtf8(loadCheck.readLine().constData()).trimmed();
}
- if (QMessageBox::question(nullptr, QObject::tr("Plugin error"),
- QObject::tr("It appears the plugin \"%1\" failed to load last startup and caused MO to crash. Do you want to disable it?\n"
- "(Please note: If this is the first time you see this message for this plugin you may want to give it another try. "
- "The plugin may be able to recover from the problem)").arg(fileName),
- QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes) {
- m_Organizer->settings().plugins().addBlacklist(fileName);
+
+ log::warn("loadcheck file found for plugin '{}'", fileName);
+
+ MOBase::TaskDialog dlg;
+
+ const auto Skip = QMessageBox::Ignore;
+ const auto Blacklist = QMessageBox::Cancel;
+ const auto Load = QMessageBox::Ok;
+
+ const auto r = dlg
+ .title(tr("Plugin error"))
+ .main(tr(
+ "Mod Organizer failed to load the plugin '%1' last time it was started.")
+ .arg(fileName))
+ .content(tr(
+ "The plugin can be skipped for this session, blacklisted, "
+ "or loaded normally, in which case it might fail again. Blacklisted "
+ "plugins can be re-enabled later in the settings."))
+ .icon(QMessageBox::Warning)
+ .button({tr("Skip this plugin"), Skip})
+ .button({tr("Blacklist this plugin"), Blacklist})
+ .button({tr("Load this plugin"), Load})
+ .exec();
+
+ switch (r)
+ {
+ case Skip:
+ log::warn("user wants to skip plugin '{}'", fileName);
+ skipPlugin = fileName;
+ break;
+
+ case Blacklist:
+ log::warn("user wants to blacklist plugin '{}'", fileName);
+ m_Organizer->settings().plugins().addBlacklist(fileName);
+ break;
+
+ case Load:
+ log::warn("user wants to load plugin '{}' anyway", fileName);
+ break;
}
+
loadCheck.close();
}
@@ -434,6 +470,11 @@ void PluginContainer::loadPlugins()
while (iter.hasNext()) {
iter.next();
+ if (skipPlugin == iter.fileName()) {
+ log::debug("plugin \"{}\" skipped for this session", iter.fileName());
+ continue;
+ }
+
if (m_Organizer) {
if (m_Organizer->settings().plugins().blacklisted(iter.fileName())) {
log::debug("plugin \"{}\" blacklisted", iter.fileName());
@@ -467,11 +508,25 @@ void PluginContainer::loadPlugins()
}
}
- // remove the load check file on success
- if (loadCheck.isOpen()) {
- loadCheck.remove();
+ if (skipPlugin.isEmpty()) {
+ // remove the load check file on success
+ if (loadCheck.isOpen()) {
+ loadCheck.remove();
+ }
+ } else {
+ // remember the plugin for next time
+ if (loadCheck.isOpen()) {
+ loadCheck.close();
+ }
+
+ log::warn("user skipped plugin '{}', remembering in loadcheck", skipPlugin);
+ loadCheck.open(QIODevice::WriteOnly);
+ loadCheck.write(skipPlugin.toUtf8());
+ loadCheck.write("\n");
+ loadCheck.flush();
}
+
bf::at_key<IPluginDiagnose>(m_Plugins).push_back(this);
if (m_Organizer) {