First step of effect dependencies handling - when an effect is loaded, load it's dependancies also.
svn path=/trunk/KDE/kdebase/workspace/; revision=690660
This commit is contained in:
parent
54fb7834a7
commit
4f093c4721
1 changed files with 28 additions and 4 deletions
32
effects.cpp
32
effects.cpp
|
@ -59,6 +59,8 @@ void EffectsHandlerImpl::reconfigure()
|
||||||
KConfigGroup conf(_config, "Plugins");
|
KConfigGroup conf(_config, "Plugins");
|
||||||
|
|
||||||
KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect");
|
KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect");
|
||||||
|
QStringList effectsToBeLoaded;
|
||||||
|
// First unload necessary effects
|
||||||
foreach( KService::Ptr service, offers )
|
foreach( KService::Ptr service, offers )
|
||||||
{
|
{
|
||||||
KPluginInfo plugininfo( service );
|
KPluginInfo plugininfo( service );
|
||||||
|
@ -66,10 +68,18 @@ void EffectsHandlerImpl::reconfigure()
|
||||||
|
|
||||||
bool isloaded = isEffectLoaded( plugininfo.pluginName() );
|
bool isloaded = isEffectLoaded( plugininfo.pluginName() );
|
||||||
bool shouldbeloaded = plugininfo.isPluginEnabled();
|
bool shouldbeloaded = plugininfo.isPluginEnabled();
|
||||||
if( shouldbeloaded && !isloaded)
|
if( !shouldbeloaded && isloaded )
|
||||||
loadEffect( plugininfo.pluginName() );
|
|
||||||
else if( !shouldbeloaded && isloaded )
|
|
||||||
unloadEffect( plugininfo.pluginName() );
|
unloadEffect( plugininfo.pluginName() );
|
||||||
|
if( shouldbeloaded )
|
||||||
|
effectsToBeLoaded.append( plugininfo.pluginName() );
|
||||||
|
}
|
||||||
|
// Then load those that should be loaded
|
||||||
|
foreach( QString effectName, effectsToBeLoaded )
|
||||||
|
{
|
||||||
|
if( !isEffectLoaded( effectName ))
|
||||||
|
{
|
||||||
|
loadEffect( effectName );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -645,7 +655,7 @@ bool EffectsHandlerImpl::loadEffect( const QString& name )
|
||||||
kError( 1212 ) << k_funcinfo << "Couldn't find effect " << name << endl;
|
kError( 1212 ) << k_funcinfo << "Couldn't find effect " << name << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
KSharedPtr<KService> service = offers.first();
|
KService::Ptr service = offers.first();
|
||||||
|
|
||||||
KLibrary* library = findEffectLibrary( service.data() );
|
KLibrary* library = findEffectLibrary( service.data() );
|
||||||
if( !library )
|
if( !library )
|
||||||
|
@ -677,6 +687,20 @@ bool EffectsHandlerImpl::loadEffect( const QString& name )
|
||||||
typedef Effect* (*t_createfunc)();
|
typedef Effect* (*t_createfunc)();
|
||||||
t_createfunc create = reinterpret_cast<t_createfunc>(create_func);
|
t_createfunc create = reinterpret_cast<t_createfunc>(create_func);
|
||||||
|
|
||||||
|
// Make sure all depenedencies have been loaded
|
||||||
|
// TODO: detect circular deps
|
||||||
|
KPluginInfo plugininfo( service );
|
||||||
|
QStringList dependencies = plugininfo.dependencies();
|
||||||
|
foreach( QString depName, dependencies )
|
||||||
|
{
|
||||||
|
if( !loadEffect(depName))
|
||||||
|
{
|
||||||
|
kError() << "EffectsHandler::loadEffect : Couldn't load dependencies for effect " << name << endl;
|
||||||
|
library->unload();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Effect* e = create();
|
Effect* e = create();
|
||||||
|
|
||||||
effect_order.insert( service->property( "X-Ordering" ).toInt(), EffectPair( name, e ));
|
effect_order.insert( service->property( "X-Ordering" ).toInt(), EffectPair( name, e ));
|
||||||
|
|
Loading…
Reference in a new issue