Add check for effect version to prevent loading of incompatible plugins.

Should work automagically, not changes in plugins needed.


svn path=/trunk/KDE/kdebase/workspace/; revision=749626
This commit is contained in:
Luboš Luňák 2007-12-17 14:10:21 +00:00
parent 44bd0185ec
commit 44cc93170d
3 changed files with 22 additions and 3 deletions

View file

@ -71,8 +71,6 @@ KDE 4.0 TODO
- disable application effects when kwin can provide them, e.g. shadow/transparency
- since API won't be stable, a version check for modules is needed
- Plasma taskbar doesn't set icon geometry
- Plasma pager doesn't set desktop layout

View file

@ -723,6 +723,22 @@ bool EffectsHandlerImpl::loadEffect( const QString& name )
return false;
}
QString version_symbol = "effect_version_" + name;
KLibrary::void_function_ptr version_func = library->resolveFunction(version_symbol.toAscii());
if( version_func == NULL )
{
kWarning( 1212 ) << "Effect " << name << " does not provide required API version, ignoring.";
return false;
}
typedef int (*t_versionfunc)();
int version = reinterpret_cast< t_versionfunc >( version_func )(); // call it
// version must be the same or less, but major must be the same
if( version > KWIN_EFFECT_API_VERSION
|| ( version >> 8 ) != KWIN_EFFECT_API_VERSION_MAJOR )
{
kWarning( 1212 ) << "Effect " << name << " requires unsupported API version " << version;
return false;
}
QString supported_symbol = "effect_supported_" + name;
KLibrary::void_function_ptr supported_func = library->resolveFunction(supported_symbol.toAscii().data());
QString create_symbol = "effect_create_" + name;

View file

@ -39,7 +39,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <assert.h>
#define KWIN_EFFECT_API_VERSION 0x000100
#define KWIN_EFFECT_API_MAKE_VERSION( major, minor ) (( major ) << 8 | ( minor ))
#define KWIN_EFFECT_API_VERSION_MAJOR 0
#define KWIN_EFFECT_API_VERSION_MINOR 1
#define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \
KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR )
class KLibrary;
class KConfigGroup;
@ -283,6 +287,7 @@ class KWIN_EXPORT Effect
#define KWIN_EFFECT( name, classname ) \
extern "C" { \
KWIN_EXPORT Effect* effect_create_kwin4_effect_##name() { return new classname; } \
KWIN_EXPORT int effect_version_kwin4_effect_##name() { return KWIN_EFFECT_API_VERSION; } \
}
/**
* Defines the function used to check whether an effect is supported