Browse Source

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).
QGC4.4
Alex Wilkinson 5 years ago committed by GitHub
parent
commit
1893a920ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/QGCToolbox.cc

4
src/QGCToolbox.cc

@ -134,13 +134,13 @@ void QGCToolbox::_scanAndLoadPlugins(QGCApplication* app) @@ -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)

Loading…
Cancel
Save