[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: patch: kwin: don't use libltdl
From: Simon Hausmann <hausmann () kde ! org>
Date: 2002-02-23 14:30:40
[Download RAW message or body]
Hi,
The attached patch makes kwin use KLibrary instead of libtldl.
Please review.
Simon
["kwin_patch.txt" (text/plain)]
Index: plugins.cpp
===================================================================
RCS file: /home/kde/kdebase/kwin/plugins.cpp,v
retrieving revision 1.25
diff -u -p -b -r1.25 plugins.cpp
--- plugins.cpp 2002/02/23 00:41:48 1.25
+++ plugins.cpp 2002/02/23 14:27:55
@@ -19,10 +19,6 @@ Copyright (C) 1999, 2000 Daniel M. Du
#include "plugins.h"
-#ifndef lt_ptr_t
-#define lt_ptr_t lt_ptr
-#endif
-
using namespace KWinInternal;
const char* defaultPlugin = "kwin_default";
@@ -32,7 +28,7 @@ PluginMgr::PluginMgr()
: QObject()
{
alloc_ptr = NULL;
- handle = 0;
+ library = 0;
pluginStr = "kwin_undefined";
updatePlugin();
@@ -40,12 +36,13 @@ PluginMgr::PluginMgr()
PluginMgr::~PluginMgr()
{
- if(handle) {
+ if(library) {
// Call the plugin's cleanup function
- lt_ptr_t deinit_func = lt_dlsym(handle, "deinit");
+ void *deinit_func = library->symbol("deinit");
if (deinit_func)
((void (*)())deinit_func)();
- lt_dlclose(handle);
+ library->unload();
+ library = 0;
}
}
@@ -73,14 +70,8 @@ Client* PluginMgr::allocateClient(Worksp
// returns true if plugin was loaded successfully
void PluginMgr::loadPlugin(QString nameStr)
{
- static bool dlregistered = false;
- lt_dlhandle oldHandle = handle;
- handle = 0;
-
- if(!dlregistered) {
- dlregistered = true;
- lt_dlinit();
- }
+ KLibrary *oldLibrary = library;
+ library = 0;
QString path = KLibLoader::findLibrary(QFile::encodeName(nameStr));
@@ -99,31 +90,31 @@ void PluginMgr::loadPlugin(QString nameS
return;
// Try loading the requested plugin
- handle = lt_dlopen(QFile::encodeName(path));
+ library = KLibLoader::self()->library(QFile::encodeName(path));
// If that fails, fall back to the default plugin
- if (!handle) {
+ if (!library) {
nameStr = defaultPlugin;
path = KLibLoader::findLibrary(QFile::encodeName(nameStr));
if (!path.isEmpty())
- handle = lt_dlopen(QFile::encodeName(path));
+ library = KLibLoader::self()->library(QFile::encodeName(path));
}
- if (!handle)
+ if (!library)
shutdownKWin(i18n("The default decoration plugin is corrupt "
"and could not be loaded!"));
// Call the plugin's initialisation function
- lt_ptr_t init_func = lt_dlsym(handle, "init");
+ void *init_func = library->symbol("init");
if (init_func)
((void (*)())init_func)();
- lt_ptr_t alloc_func = lt_dlsym(handle, "allocate");
+ void *alloc_func = library->symbol("allocate");
if(alloc_func) {
alloc_ptr = (Client* (*)(Workspace *ws, WId w, int tool))alloc_func;
} else {
qWarning("KWin: The library %s is not a KWin plugin.", path.latin1());
- lt_dlclose(handle);
+ library->unload();
exit(1);
}
@@ -131,17 +122,17 @@ void PluginMgr::loadPlugin(QString nameS
emit resetAllClients();
// Call the old plugin's cleanup function
- if(oldHandle) {
- lt_ptr_t deinit_func = lt_dlsym(oldHandle, "deinit");
+ if(oldLibrary) {
+ void *deinit_func = oldLibrary->symbol("deinit");
if (deinit_func)
((void (*)())deinit_func)();
- lt_dlclose(oldHandle);
+ oldLibrary->unload();
}
}
void PluginMgr::resetPlugin()
{
- lt_ptr_t reset_func = lt_dlsym(handle, "reset");
+ void *reset_func = library->symbol("reset");
if (reset_func)
((void (*)())reset_func)();
}
Index: plugins.h
===================================================================
RCS file: /home/kde/kdebase/kwin/plugins.h,v
retrieving revision 1.10
diff -u -p -b -r1.10 plugins.h
--- plugins.h 2001/06/07 11:35:06 1.10
+++ plugins.h 2002/02/23 14:27:55
@@ -8,9 +8,9 @@ Copyright (C) 1999, 2000 Daniel M. Du
#include <qpopupmenu.h>
#include <qstringlist.h>
-#include <ltdl.h>
class QFileInfo;
+class KLibrary;
namespace KWinInternal {
@@ -34,7 +34,7 @@ signals:
protected:
void shutdownKWin(const QString& error_msg);
Client* (*alloc_ptr)(Workspace *ws, WId w, int tool);
- lt_dlhandle handle;
+ KLibrary *library;
QString pluginStr;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic