Commit f0413a44 authored by Dennis Nienhüser's avatar Dennis Nienhüser
Browse files

Unload plugins at shutdown, fix memory leaks

Note that this might require changes in 3rd party plugins as unloading
happens very late. See e.g. 485db2e8 and fca70af3.
parent 3d273532
......@@ -209,8 +209,8 @@ MarbleModel::MarbleModel( QObject *parent )
connect(&d->m_clock, SIGNAL(timeChanged()),
&d->m_sunLocator, SLOT(update()) );
d->m_pluginManager.addPositionProviderPlugin( new PlacemarkPositionProviderPlugin( this ) );
d->m_pluginManager.addPositionProviderPlugin( new RouteSimulationPositionProviderPlugin( this ) );
d->m_pluginManager.addPositionProviderPlugin(new PlacemarkPositionProviderPlugin(this, this));
d->m_pluginManager.addPositionProviderPlugin(new RouteSimulationPositionProviderPlugin(this, this));
}
MarbleModel::~MarbleModel()
......
......@@ -21,8 +21,8 @@
using namespace Marble;
PlacemarkPositionProviderPlugin::PlacemarkPositionProviderPlugin( MarbleModel *marbleModel )
: PositionProviderPlugin(),
PlacemarkPositionProviderPlugin::PlacemarkPositionProviderPlugin( MarbleModel *marbleModel, QObject* parent )
: PositionProviderPlugin(parent),
m_marbleModel( marbleModel ),
m_placemark( 0 ),
m_speed( 0 ),
......
......@@ -31,7 +31,7 @@ class PlacemarkPositionProviderPlugin: public PositionProviderPlugin
Q_INTERFACES( Marble::PositionProviderPluginInterface )
public:
explicit PlacemarkPositionProviderPlugin( MarbleModel *marbleModel );
explicit PlacemarkPositionProviderPlugin( MarbleModel *marbleModel, QObject* parent=nullptr );
QString name() const override;
QString nameId() const override;
......
......@@ -36,8 +36,9 @@ namespace Marble
class PluginManagerPrivate
{
public:
PluginManagerPrivate()
: m_pluginsLoaded(false)
PluginManagerPrivate(PluginManager* parent)
: m_pluginsLoaded(false),
m_parent(parent)
{
}
......@@ -52,6 +53,7 @@ class PluginManagerPrivate
QList<const ReverseGeocodingRunnerPlugin *> m_reverseGeocodingRunnerPlugins;
QList<RoutingRunnerPlugin *> m_routingRunnerPlugins;
QList<const ParseRunnerPlugin *> m_parsingRunnerPlugins;
PluginManager* m_parent;
static QStringList m_blacklist;
static QStringList m_whitelist;
......@@ -69,7 +71,7 @@ PluginManagerPrivate::~PluginManagerPrivate()
}
PluginManager::PluginManager( QObject *parent ) : QObject( parent ),
d( new PluginManagerPrivate() )
d( new PluginManagerPrivate(this) )
{
//Checking assets:/plugins for uninstalled plugins
#ifdef Q_OS_ANDROID
......@@ -248,7 +250,7 @@ void PluginManagerPrivate::loadPlugins()
continue;
}
#endif
QPluginLoader* loader = new QPluginLoader( path );
QPluginLoader* loader = new QPluginLoader( path, m_parent );
QObject * obj = loader->instance();
......
......@@ -21,8 +21,9 @@ public:
}
};
PositionProviderPlugin::PositionProviderPlugin()
: d( new PositionProviderPluginPrivate() )
PositionProviderPlugin::PositionProviderPlugin(QObject *parent)
: QObject(parent),
d( new PositionProviderPluginPrivate() )
{
}
......
......@@ -48,7 +48,7 @@ class MARBLE_EXPORT PositionProviderPlugin : public QObject, public PositionProv
const GeoDataAccuracy& accuracy ) const;
protected:
PositionProviderPlugin();
PositionProviderPlugin(QObject* parent=0);
private:
Q_DISABLE_COPY( PositionProviderPlugin )
......
......@@ -98,8 +98,8 @@ GeoDataAccuracy RouteSimulationPositionProviderPlugin::accuracy() const
return result;
}
RouteSimulationPositionProviderPlugin::RouteSimulationPositionProviderPlugin( MarbleModel *marbleModel ) :
PositionProviderPlugin(),
RouteSimulationPositionProviderPlugin::RouteSimulationPositionProviderPlugin(MarbleModel *marbleModel , QObject *parent) :
PositionProviderPlugin(parent),
m_marbleModel( marbleModel ),
m_currentIndex( -2 ),
m_status( PositionProviderStatusUnavailable ),
......
......@@ -32,7 +32,7 @@ class RouteSimulationPositionProviderPlugin: public PositionProviderPlugin
Q_INTERFACES( Marble::PositionProviderPluginInterface )
public:
explicit RouteSimulationPositionProviderPlugin( MarbleModel *marbleModel );
explicit RouteSimulationPositionProviderPlugin(MarbleModel *marbleModel, QObject* parent=nullptr);
~RouteSimulationPositionProviderPlugin() override;
// Implementing PluginInterface
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment