Skip to content

Commit

Permalink
Prevent runtime_error exceptions from plugins crashing the main app (#…
Browse files Browse the repository at this point in the history
…812)

Catch runtime_error exceptions thrown from the plugins and skip the throwing plugins, so that the main app can continue its normal operation.
  • Loading branch information
ozzdemir authored Apr 22, 2023
1 parent 5560f02 commit 97bf27e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion plotjuggler_app/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,16 @@ QStringList MainWindow::initializePlugins(QString directory_name)

QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(filename), this);

QObject* plugin = pluginLoader.instance();
QObject* plugin;
try
{
plugin = pluginLoader.instance();
}
catch (std::runtime_error& err)
{
qDebug() << QString("%1: skipping, because it threw the following exception: %2").arg(filename).arg(err.what());
continue;
}
if (plugin && dynamic_cast<PlotJugglerPlugin*>(plugin))
{
auto class_name = pluginLoader.metaData().value("className").toString();
Expand Down

0 comments on commit 97bf27e

Please sign in to comment.