Skip to content

Commit

Permalink
Store loaded plugins internally in TPP pipeline widget (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
marip8 authored Oct 9, 2024
1 parent ffd8182 commit 3fb6b9e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions noether_gui/include/noether_gui/widgets/tpp_pipeline_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ class TPPPipelineWidget : public QWidget
PluginLoaderWidget<MeshModifierWidgetPlugin>* mesh_modifier_loader_widget_;
PluginLoaderWidget<ToolPathModifierWidgetPlugin>* tool_path_modifier_loader_widget_;
Ui::TPPPipeline* ui_;

/**
* @brief Container for holding all loaded plugins
* @details All loaded plugins must be held in scope in order to prevent the plugin libraries from being unloaded
*/
std::set<std::shared_ptr<ToolPathPlannerWidgetPlugin>> plugins_;
};

} // namespace noether
5 changes: 5 additions & 0 deletions noether_gui/src/widgets/tpp_pipeline_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ TPPPipelineWidget::TPPPipelineWidget(boost_plugin_loader::PluginLoader loader, Q
else
{
auto plugin = loader_.createInstance<ToolPathPlannerWidgetPlugin>(plugin_name.toStdString());

// Store the plugin so the library providing the plugin (and objects generated by the plugin) does not get
// unloaded
plugins_.insert(plugin);

ui_->stacked_widget->addWidget(plugin->create(this, {}));
}
}
Expand Down

0 comments on commit 3fb6b9e

Please sign in to comment.