From 1893a920ec6257b2541e69a9491fbe94ba6c66a7 Mon Sep 17 00:00:00 2001 From: Alex Wilkinson Date: Wed, 1 Apr 2020 17:05:00 +0100 Subject: [PATCH] Correctly set parent of QGCCorePlugin QGCCorePlugin is currently constructed with a QGCToolbox* toolbx parameter of null. This is because at the time QGCCorePlugin (or an actual custom plugin) is constructed app->toolbox() is null. _scanAndLoadPlugins() is called as part of the QGCToolbox constructor where all toolbox classes use the same format: _class = new Class(app, this); The creation of QGCCorePlugin should follow the same pattern. The practical issue I had with this is that because the parent is not set correctly, QGCCorePlugin is not destructed when the app is closed. This means any code in the destructor is not run. (QGCCorePlugin itself has as a destructor which is currently not being called). --- src/QGCToolbox.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/QGCToolbox.cc b/src/QGCToolbox.cc index bda8ec103..a6bbeef1a 100644 --- a/src/QGCToolbox.cc +++ b/src/QGCToolbox.cc @@ -134,13 +134,13 @@ void QGCToolbox::_scanAndLoadPlugins(QGCApplication* app) { #if defined (QGC_CUSTOM_BUILD) //-- Create custom plugin (Static) - _corePlugin = (QGCCorePlugin*) new CUSTOMCLASS(app, app->toolbox()); + _corePlugin = (QGCCorePlugin*) new CUSTOMCLASS(app, this); if(_corePlugin) { return; } #endif //-- No plugins found, use default instance - _corePlugin = new QGCCorePlugin(app, app->toolbox()); + _corePlugin = new QGCCorePlugin(app, this); } QGCTool::QGCTool(QGCApplication* app, QGCToolbox* toolbox) -- 2.22.0