faster configuration changes. No crashes when reconfiguring kwin

several times with invalid plugin strings (happens when running
today's kpersonalizer)

svn path=/trunk/kdebase/kwin/; revision=139725
This commit is contained in:
Matthias Ettrich 2002-03-01 01:34:54 +00:00
parent f55f2682cf
commit dd29e3723c
5 changed files with 15 additions and 27 deletions

View file

@ -271,9 +271,6 @@ void Options::reload()
globalConfig.setGroup("KDE");
d->fade_tooltips = globalConfig.readBoolEntry("EffectFadeTooltip", false);
d->animate_tooltips = globalConfig.readBoolEntry("EffectAnimateTooltip", false);
emit resetPlugin();
emit resetClients();
}

View file

@ -323,9 +323,6 @@ public:
public slots:
void reload();
signals:
void resetPlugin();
void resetClients();
protected:
QFont activeFont, inactiveFont, activeFontSmall, inactiveFontSmall;

View file

@ -32,7 +32,9 @@ PluginMgr::PluginMgr()
library = 0;
pluginStr = "kwin_undefined";
updatePlugin();
KConfig *config = KGlobal::config();
config->setGroup("Style");
loadPlugin( config->readEntry("PluginLib", defaultPlugin) );
}
PluginMgr::~PluginMgr()
@ -52,10 +54,11 @@ void PluginMgr::updatePlugin()
KConfig *config = KGlobal::config();
config->reparseConfiguration();
config->setGroup("Style");
QString newPlugin = config->readEntry("PluginLib", defaultPlugin);
if (newPlugin != pluginStr)
loadPlugin(newPlugin);
if ( !loadPlugin( config->readEntry("PluginLib", defaultPlugin )) && library ) {
void *reset_func = library->symbol("reset");
if (reset_func)
((void (*)())reset_func)();
}
}
Client* PluginMgr::allocateClient(Workspace *ws, WId w, bool tool)
@ -69,7 +72,7 @@ Client* PluginMgr::allocateClient(Workspace *ws, WId w, bool tool)
}
// returns true if plugin was loaded successfully
void PluginMgr::loadPlugin(QString nameStr)
bool PluginMgr::loadPlugin(QString nameStr)
{
KLibrary *oldLibrary = library;
library = 0;
@ -88,14 +91,17 @@ void PluginMgr::loadPlugin(QString nameStr)
// Check if this library is not already loaded.
if(pluginStr == nameStr)
return;
return FALSE;
// Try loading the requested plugin
library = KLibLoader::self()->library(QFile::encodeName(path));
// If that fails, fall back to the default plugin
if (!library) {
kdDebug() << " could not load library, try default plugin again" << endl;
nameStr = defaultPlugin;
if ( pluginStr == nameStr )
return FALSE;
path = KLibLoader::findLibrary(QFile::encodeName(nameStr));
if (!path.isEmpty())
library = KLibLoader::self()->library(QFile::encodeName(path));
@ -129,13 +135,7 @@ void PluginMgr::loadPlugin(QString nameStr)
((void (*)())deinit_func)();
oldLibrary->unload();
}
}
void PluginMgr::resetPlugin()
{
void *reset_func = library->symbol("reset");
if (reset_func)
((void (*)())reset_func)();
return TRUE;
}
void PluginMgr::shutdownKWin(const QString &error_msg)

View file

@ -24,11 +24,10 @@ public:
PluginMgr();
~PluginMgr();
Client *allocateClient(Workspace *ws, WId w, bool tool);
void loadPlugin(QString name);
bool loadPlugin(QString name);
QString currentPlugin() { return pluginStr; }
public slots:
void updatePlugin();
void resetPlugin();
signals:
void resetAllClients();
protected:

View file

@ -2005,18 +2005,13 @@ void Workspace::reconfigure()
void Workspace::slotReconfigure()
{
kdDebug(1212) << "Workspace::slotReconfigure()" << endl;
reconfigureTimer.stop();
KGlobal::config()->reparseConfiguration();
options->reload();
tab_box->reconfigure();
readShortcuts();
mgr->updatePlugin();
// NO need whatsoever to call slotResetAllClientsDelayed here,
// updatePlugin resets all clients if necessary anyway.
if (options->electricBorders() == Options::ElectricAlways)
createBorderWindows();