Use KLibrary::hasSymbol() before actually using symbol() in order to
avoid warning from KLibrary in case the symbol doesn't exist. svn path=/trunk/kdebase/kwin/; revision=178239
This commit is contained in:
parent
3c76926248
commit
88c7d513f6
1 changed files with 31 additions and 19 deletions
18
plugins.cpp
18
plugins.cpp
|
@ -42,9 +42,11 @@ PluginMgr::~PluginMgr()
|
||||||
{
|
{
|
||||||
if(library) {
|
if(library) {
|
||||||
// Call the plugin's cleanup function
|
// Call the plugin's cleanup function
|
||||||
|
if( library->hasSymbol("deinit")) {
|
||||||
void *deinit_func = library->symbol("deinit");
|
void *deinit_func = library->symbol("deinit");
|
||||||
if (deinit_func)
|
if (deinit_func)
|
||||||
((void (*)())deinit_func)();
|
((void (*)())deinit_func)();
|
||||||
|
}
|
||||||
library->unload();
|
library->unload();
|
||||||
library = 0;
|
library = 0;
|
||||||
}
|
}
|
||||||
|
@ -56,10 +58,12 @@ void PluginMgr::updatePlugin()
|
||||||
config->reparseConfiguration();
|
config->reparseConfiguration();
|
||||||
config->setGroup("Style");
|
config->setGroup("Style");
|
||||||
if ( !loadPlugin( config->readEntry("PluginLib", defaultPlugin )) && library ) {
|
if ( !loadPlugin( config->readEntry("PluginLib", defaultPlugin )) && library ) {
|
||||||
|
if( library->hasSymbol("reset")) {
|
||||||
void *reset_func = library->symbol("reset");
|
void *reset_func = library->symbol("reset");
|
||||||
if (reset_func)
|
if (reset_func)
|
||||||
((void (*)())reset_func)();
|
((void (*)())reset_func)();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Client* PluginMgr::createClient(Workspace *ws, WId w, NET::WindowType type)
|
Client* PluginMgr::createClient(Workspace *ws, WId w, NET::WindowType type)
|
||||||
|
@ -113,17 +117,23 @@ bool PluginMgr::loadPlugin(QString nameStr)
|
||||||
"and could not be loaded!"));
|
"and could not be loaded!"));
|
||||||
|
|
||||||
// Call the plugin's initialisation function
|
// Call the plugin's initialisation function
|
||||||
|
if( library->hasSymbol("init")) {
|
||||||
void *init_func = library->symbol("init");
|
void *init_func = library->symbol("init");
|
||||||
if (init_func)
|
if (init_func)
|
||||||
((void (*)())init_func)();
|
((void (*)())init_func)();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( library->hasSymbol("create")) {
|
||||||
void* create_func = library->symbol("create");
|
void* create_func = library->symbol("create");
|
||||||
if(create_func) {
|
if(create_func) {
|
||||||
create_ptr = (Client* (*)(Workspace *ws, WId w, NET::WindowType))create_func;
|
create_ptr = (Client* (*)(Workspace *ws, WId w, NET::WindowType))create_func;
|
||||||
}
|
}
|
||||||
create_func = library->symbol("allocate");
|
}
|
||||||
if(create_func) {
|
if( library->hasSymbol("allocate")) {
|
||||||
old_create_ptr = (Client* (*)(Workspace *ws, WId w, int tool))create_func;
|
void* allocate_func = library->symbol("allocate");
|
||||||
|
if(allocate_func) {
|
||||||
|
old_create_ptr = (Client* (*)(Workspace *ws, WId w, int tool))allocate_func;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(!create_ptr && !old_create_ptr) {
|
if(!create_ptr && !old_create_ptr) {
|
||||||
kdWarning() << "KWin: The library " << path << " is not a KWin plugin." << endl;
|
kdWarning() << "KWin: The library " << path << " is not a KWin plugin." << endl;
|
||||||
|
@ -136,9 +146,11 @@ bool PluginMgr::loadPlugin(QString nameStr)
|
||||||
|
|
||||||
// Call the old plugin's cleanup function
|
// Call the old plugin's cleanup function
|
||||||
if(oldLibrary) {
|
if(oldLibrary) {
|
||||||
|
if( library->hasSymbol("deinit")) {
|
||||||
void *deinit_func = oldLibrary->symbol("deinit");
|
void *deinit_func = oldLibrary->symbol("deinit");
|
||||||
if (deinit_func)
|
if (deinit_func)
|
||||||
((void (*)())deinit_func)();
|
((void (*)())deinit_func)();
|
||||||
|
}
|
||||||
oldLibrary->unload();
|
oldLibrary->unload();
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
Loading…
Reference in a new issue