[Marble-commits] KDE/kdeedu/marble/src
Dennis Nienhüser
earthwings at gentoo.org
Thu Aug 26 14:23:39 CEST 2010
SVN commit 1168304 by nienhueser:
Stricter plugin load checks: Refuse to load plugins with older interface versions. Fixes incompatible/old plugins crashing Marble.
CCBUG: 239831
RB: 5149
M +0 -1 lib/AbstractDataPlugin.h
M +30 -29 lib/PluginManager.cpp
M +0 -1 lib/RenderPlugin.h
M +2 -2 lib/RunnerPlugin.h
M +1 -0 plugins/network/qnam/QNamNetworkPlugin.h
M +1 -0 plugins/positionprovider/geoclue/GeoCluePositionProviderPlugin.h
M +1 -0 plugins/positionprovider/gpsd/GpsdPositionProviderPlugin.h
M +1 -0 plugins/positionprovider/maemo/MaemoPositionProviderPlugin.h
M +1 -0 plugins/render/fileview/FileViewFloatItem.h
M +2 -1 plugins/render/navigation/NavigationFloatItem.h
M +2 -0 plugins/runner/gosmore/GosmorePlugin.h
M +1 -0 plugins/runner/hostip/HostipPlugin.h
M +2 -0 plugins/runner/latlon/LatLonPlugin.h
M +2 -0 plugins/runner/localdatabase/LocalDatabasePlugin.h
M +1 -0 plugins/runner/namefinder/NameFinderPlugin.h
M +2 -0 plugins/runner/nominatim/NominatimPlugin.h
M +2 -0 plugins/runner/openrouteservice/OpenRouteServicePlugin.h
M +2 -0 plugins/runner/routino/RoutinoPlugin.h
M +2 -0 plugins/runner/traveling-salesman/TravelingSalesmanPlugin.h
M +2 -0 plugins/runner/yours/YoursPlugin.h
--- trunk/KDE/kdeedu/marble/src/lib/AbstractDataPlugin.h #1168303:1168304
@@ -40,7 +40,6 @@
class MARBLE_EXPORT AbstractDataPlugin : public RenderPlugin
{
Q_OBJECT
- Q_INTERFACES( Marble::RenderPluginInterface )
public:
AbstractDataPlugin();
--- trunk/KDE/kdeedu/marble/src/lib/PluginManager.cpp #1168303:1168304
@@ -133,6 +133,23 @@
return d->m_runnerPlugins;
}
+/** Append obj to the given plugins list if it inherits both T and U */
+template<class T, class U>
+bool appendPlugin( QObject * obj, const QString &fileName, QList<T*> &plugins )
+{
+ if ( qobject_cast<T*>( obj ) && qobject_cast<U*>( obj ) ) {
+ Q_ASSERT( obj->metaObject()->superClass() ); // all our plugins have a super class
+ mDebug() << obj->metaObject()->superClass()->className()
+ << "plugin loaded from" << MarbleDirs::pluginPath( fileName );
+ T* plugin = qobject_cast<T*>( obj );
+ Q_ASSERT( plugin ); // checked above
+ plugins.append( plugin );
+ return true;
+ }
+
+ return false;
+}
+
void PluginManagerPrivate::loadPlugins()
{
if (m_pluginsLoaded)
@@ -165,41 +182,25 @@
QObject * obj = loader.instance();
- RenderPlugin * renderPlugin = 0;
- NetworkPlugin * networkPlugin = 0;
- PositionProviderPlugin * positionProviderPlugin = 0;
- RunnerPlugin * runnerPlugin = 0;
if ( obj ) {
- if ( obj->inherits( "Marble::RenderPlugin" ) ) {
- mDebug() << "render plugin found" << MarbleDirs::pluginPath( fileName );
- renderPlugin = qobject_cast<RenderPlugin *>( obj );
- m_renderPluginTemplates.append( renderPlugin );
+ bool isPlugin = appendPlugin<RenderPlugin, RenderPluginInterface>
+ ( obj, fileName, m_renderPluginTemplates );
+ isPlugin = isPlugin || appendPlugin<NetworkPlugin, NetworkPluginInterface>
+ ( obj, fileName, m_networkPluginTemplates );
+ isPlugin = isPlugin || appendPlugin<PositionProviderPlugin, PositionProviderPluginInterface>
+ ( obj, fileName, m_positionProviderPluginTemplates );
+ isPlugin = isPlugin || appendPlugin<RunnerPlugin, RunnerPlugin>
+ ( obj, fileName, m_runnerPlugins ); // intentionally T==U
+ if ( !isPlugin ) {
+ mDebug() << "Plugin failure:" << fileName << "is a plugin, but it does not implement the "
+ << "right interfaces or it was compiled against an old version of Marble. Ignoring it.";
}
- else if ( obj->inherits( "Marble::NetworkPlugin" ) ) {
- mDebug() << "network plugin found" << MarbleDirs::pluginPath( fileName );
- networkPlugin = qobject_cast<NetworkPlugin *>( obj );
- m_networkPluginTemplates.append( networkPlugin );
- }
- else if ( obj->inherits( "Marble::PositionProviderPlugin" ) ) {
- mDebug() << "position provider plugin found" << MarbleDirs::pluginPath( fileName );
- positionProviderPlugin = qobject_cast<PositionProviderPlugin *>( obj );
- m_positionProviderPluginTemplates.append( positionProviderPlugin );
- } else if ( obj->inherits( "Marble::RunnerPlugin" ) ) {
- mDebug() << "runner plugin found" << MarbleDirs::pluginPath( fileName );
- runnerPlugin = qobject_cast<RunnerPlugin *>( obj );
- Q_ASSERT( runnerPlugin && "Unexpected cast failure when loading RunnerPlugin" );
- m_runnerPlugins.append( runnerPlugin );
} else {
- mDebug() << "Unknown file or plugin type in plugin directoy: " << fileName;
+ mDebug() << "Plugin failure:" << fileName << "is not a valid Marble Plugin:"
+ << loader.errorString();
}
}
- if( !renderPlugin && !networkPlugin && !positionProviderPlugin && !runnerPlugin ) {
- mDebug() << "Plugin Failure: " << fileName << " is not a valid Marble Plugin:";
- mDebug() << loader.errorString();
- }
- }
-
m_pluginsLoaded = true;
qDebug("Time elapsed: %d ms", t.elapsed());
}
--- trunk/KDE/kdeedu/marble/src/lib/RenderPlugin.h #1168303:1168304
@@ -39,7 +39,6 @@
class MARBLE_EXPORT RenderPlugin : public QObject, public RenderPluginInterface
{
Q_OBJECT
- Q_INTERFACES( Marble::RenderPluginInterface )
public:
/**
--- trunk/KDE/kdeedu/marble/src/lib/RunnerPlugin.h #1168303:1168304
@@ -26,8 +26,6 @@
{
Q_OBJECT
- Q_INTERFACES( Marble::PluginInterface )
-
public:
enum Capability {
None = 0x0, // The plugin is useless
@@ -104,4 +102,6 @@
Q_DECLARE_OPERATORS_FOR_FLAGS(Marble::RunnerPlugin::Capabilities)
+Q_DECLARE_INTERFACE( Marble::RunnerPlugin, "org.kde.Marble.RunnerPlugin/1.00" )
+
#endif // MARBLE_RUNNERPLUGIN_H
--- trunk/KDE/kdeedu/marble/src/plugins/network/qnam/QNamNetworkPlugin.h #1168303:1168304
@@ -20,6 +20,7 @@
class QNamNetworkPlugin: public NetworkPlugin
{
Q_OBJECT
+ Q_INTERFACES( Marble::NetworkPluginInterface )
public:
QNamNetworkPlugin();
--- trunk/KDE/kdeedu/marble/src/plugins/positionprovider/geoclue/GeoCluePositionProviderPlugin.h #1168303:1168304
@@ -29,6 +29,7 @@
class GeoCluePositionProviderPlugin: public PositionProviderPlugin
{
Q_OBJECT
+ Q_INTERFACES( Marble::PositionProviderPluginInterface )
public:
GeoCluePositionProviderPlugin();
--- trunk/KDE/kdeedu/marble/src/plugins/positionprovider/gpsd/GpsdPositionProviderPlugin.h #1168303:1168304
@@ -25,6 +25,7 @@
class GpsdPositionProviderPlugin: public PositionProviderPlugin
{
Q_OBJECT
+ Q_INTERFACES( Marble::PositionProviderPluginInterface )
public:
GpsdPositionProviderPlugin();
--- trunk/KDE/kdeedu/marble/src/plugins/positionprovider/maemo/MaemoPositionProviderPlugin.h #1168303:1168304
@@ -21,6 +21,7 @@
class MaemoPositionProviderPlugin: public PositionProviderPlugin
{
Q_OBJECT
+ Q_INTERFACES( Marble::PositionProviderPluginInterface )
public:
MaemoPositionProviderPlugin();
--- trunk/KDE/kdeedu/marble/src/plugins/render/fileview/FileViewFloatItem.h #1168303:1168304
@@ -31,6 +31,7 @@
class FileViewFloatItem: public AbstractFloatItem
{
Q_OBJECT
+ Q_INTERFACES( Marble::RenderPluginInterface )
MARBLE_PLUGIN(FileViewFloatItem)
public:
--- trunk/KDE/kdeedu/marble/src/plugins/render/navigation/NavigationFloatItem.h #1168303:1168304
@@ -36,7 +36,8 @@
class NavigationFloatItem: public AbstractFloatItem
{
Q_OBJECT
-//Q_INTERFACES( MarbleLayerInterface )
+ Q_INTERFACES( Marble::RenderPluginInterface )
+
MARBLE_PLUGIN( NavigationFloatItem )
public:
explicit NavigationFloatItem( const QPointF &point = QPointF( -10, -10 ) );
--- trunk/KDE/kdeedu/marble/src/plugins/runner/gosmore/GosmorePlugin.h #1168303:1168304
@@ -20,6 +20,8 @@
class GosmorePlugin : public RunnerPlugin
{
Q_OBJECT
+ Q_INTERFACES( Marble::RunnerPlugin )
+
public:
explicit GosmorePlugin( QObject *parent = 0 );
--- trunk/KDE/kdeedu/marble/src/plugins/runner/hostip/HostipPlugin.h #1168303:1168304
@@ -20,6 +20,7 @@
class HostipPlugin : public RunnerPlugin
{
Q_OBJECT
+ Q_INTERFACES( Marble::RunnerPlugin )
public:
explicit HostipPlugin( QObject *parent = 0 );
--- trunk/KDE/kdeedu/marble/src/plugins/runner/latlon/LatLonPlugin.h #1168303:1168304
@@ -20,6 +20,8 @@
class LatLonPlugin : public RunnerPlugin
{
Q_OBJECT
+ Q_INTERFACES( Marble::RunnerPlugin )
+
public:
explicit LatLonPlugin( QObject *parent = 0 );
--- trunk/KDE/kdeedu/marble/src/plugins/runner/localdatabase/LocalDatabasePlugin.h #1168303:1168304
@@ -20,6 +20,8 @@
class LocalDatabasePlugin : public RunnerPlugin
{
Q_OBJECT
+ Q_INTERFACES( Marble::RunnerPlugin )
+
public:
explicit LocalDatabasePlugin(QObject *parent = 0);
--- trunk/KDE/kdeedu/marble/src/plugins/runner/namefinder/NameFinderPlugin.h #1168303:1168304
@@ -20,6 +20,7 @@
class NameFinderPlugin : public RunnerPlugin
{
Q_OBJECT
+ Q_INTERFACES( Marble::RunnerPlugin )
public:
explicit NameFinderPlugin( QObject *parent = 0 );
--- trunk/KDE/kdeedu/marble/src/plugins/runner/nominatim/NominatimPlugin.h #1168303:1168304
@@ -20,6 +20,8 @@
class NominatimPlugin : public RunnerPlugin
{
Q_OBJECT
+ Q_INTERFACES( Marble::RunnerPlugin )
+
public:
explicit NominatimPlugin( QObject *parent = 0 );
--- trunk/KDE/kdeedu/marble/src/plugins/runner/openrouteservice/OpenRouteServicePlugin.h #1168303:1168304
@@ -20,6 +20,8 @@
class OpenRouteServicePlugin : public RunnerPlugin
{
Q_OBJECT
+ Q_INTERFACES( Marble::RunnerPlugin )
+
public:
explicit OpenRouteServicePlugin( QObject *parent = 0 );
--- trunk/KDE/kdeedu/marble/src/plugins/runner/routino/RoutinoPlugin.h #1168303:1168304
@@ -20,6 +20,8 @@
class RoutinoPlugin : public RunnerPlugin
{
Q_OBJECT
+ Q_INTERFACES( Marble::RunnerPlugin )
+
public:
explicit RoutinoPlugin( QObject *parent = 0 );
--- trunk/KDE/kdeedu/marble/src/plugins/runner/traveling-salesman/TravelingSalesmanPlugin.h #1168303:1168304
@@ -20,6 +20,8 @@
class TravelingSalesmanPlugin : public RunnerPlugin
{
Q_OBJECT
+ Q_INTERFACES( Marble::RunnerPlugin )
+
public:
explicit TravelingSalesmanPlugin( QObject *parent = 0 );
--- trunk/KDE/kdeedu/marble/src/plugins/runner/yours/YoursPlugin.h #1168303:1168304
@@ -20,6 +20,8 @@
class YoursPlugin : public RunnerPlugin
{
Q_OBJECT
+ Q_INTERFACES( Marble::RunnerPlugin )
+
public:
explicit YoursPlugin( QObject *parent = 0 );
More information about the Marble-commits
mailing list