[Marble-commits] branches/KDE/4.5/kdeedu/marble/src
Dennis Nienhüser
earthwings at gentoo.org
Thu Aug 26 15:04:09 CEST 2010
SVN commit 1168342 by nienhueser:
Stricter plugin load checks: Refuse to load plugins with older interface versions. Fixes incompatible/old plugins crashing Marble. Backport of commit 1168304.
BUG: 239831
RB: 5149
M +0 -1 lib/AbstractDataPlugin.h
M +29 -22 lib/PluginManager.cpp
M +0 -1 lib/RenderPlugin.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
--- branches/KDE/4.5/kdeedu/marble/src/lib/AbstractDataPlugin.h #1168341:1168342
@@ -40,7 +40,6 @@
class MARBLE_EXPORT AbstractDataPlugin : public RenderPlugin
{
Q_OBJECT
- Q_INTERFACES( Marble::RenderPluginInterface )
public:
AbstractDataPlugin();
--- branches/KDE/4.5/kdeedu/marble/src/lib/PluginManager.cpp #1168341:1168342
@@ -125,6 +125,23 @@
return result;
}
+/** 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)
@@ -155,33 +172,23 @@
QObject * obj = loader.instance();
- RenderPlugin * renderPlugin = 0;
- NetworkPlugin * networkPlugin = 0;
- PositionProviderPlugin * positionProviderPlugin = 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 );
+ 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 {
+ mDebug() << "Plugin failure:" << fileName << "is not a valid Marble Plugin:"
+ << loader.errorString();
}
- else if ( obj->inherits( "Marble::PositionProviderPlugin" ) ) {
- mDebug() << "position provider plugin found" << MarbleDirs::pluginPath( fileName );
- positionProviderPlugin = qobject_cast<PositionProviderPlugin *>( obj );
- m_positionProviderPluginTemplates.append( positionProviderPlugin );
}
- }
- if( !renderPlugin && !networkPlugin && !positionProviderPlugin) {
- mDebug() << "Plugin Failure: " << fileName << " is not a valid Marble Plugin:";
- mDebug() << loader.errorString();
- }
- }
-
m_pluginsLoaded = true;
qDebug("Time elapsed: %d ms", t.elapsed());
}
--- branches/KDE/4.5/kdeedu/marble/src/lib/RenderPlugin.h #1168341:1168342
@@ -39,7 +39,6 @@
class MARBLE_EXPORT RenderPlugin : public QObject, public RenderPluginInterface
{
Q_OBJECT
- Q_INTERFACES( Marble::RenderPluginInterface )
public:
/**
--- branches/KDE/4.5/kdeedu/marble/src/plugins/network/qnam/QNamNetworkPlugin.h #1168341:1168342
@@ -20,6 +20,7 @@
class QNamNetworkPlugin: public NetworkPlugin
{
Q_OBJECT
+ Q_INTERFACES( Marble::NetworkPluginInterface )
public:
QNamNetworkPlugin();
--- branches/KDE/4.5/kdeedu/marble/src/plugins/positionprovider/geoclue/GeoCluePositionProviderPlugin.h #1168341:1168342
@@ -29,6 +29,7 @@
class GeoCluePositionProviderPlugin: public PositionProviderPlugin
{
Q_OBJECT
+ Q_INTERFACES( Marble::PositionProviderPluginInterface )
public:
GeoCluePositionProviderPlugin();
--- branches/KDE/4.5/kdeedu/marble/src/plugins/positionprovider/gpsd/GpsdPositionProviderPlugin.h #1168341:1168342
@@ -25,6 +25,7 @@
class GpsdPositionProviderPlugin: public PositionProviderPlugin
{
Q_OBJECT
+ Q_INTERFACES( Marble::PositionProviderPluginInterface )
public:
GpsdPositionProviderPlugin();
--- branches/KDE/4.5/kdeedu/marble/src/plugins/positionprovider/maemo/MaemoPositionProviderPlugin.h #1168341:1168342
@@ -21,6 +21,7 @@
class MaemoPositionProviderPlugin: public PositionProviderPlugin
{
Q_OBJECT
+ Q_INTERFACES( Marble::PositionProviderPluginInterface )
public:
MaemoPositionProviderPlugin();
--- branches/KDE/4.5/kdeedu/marble/src/plugins/render/fileview/FileViewFloatItem.h #1168341:1168342
@@ -31,6 +31,7 @@
class FileViewFloatItem: public AbstractFloatItem
{
Q_OBJECT
+ Q_INTERFACES( Marble::RenderPluginInterface )
MARBLE_PLUGIN(FileViewFloatItem)
public:
--- branches/KDE/4.5/kdeedu/marble/src/plugins/render/navigation/NavigationFloatItem.h #1168341:1168342
@@ -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 ) );
More information about the Marble-commits
mailing list