Fix plugin unloading / cleanup

svn-id: r30785
This commit is contained in:
Max Horn 2008-02-04 07:38:42 +00:00
parent afa731b0af
commit dd7fcd6867
5 changed files with 8 additions and 5 deletions

View File

@ -76,6 +76,7 @@ public:
return ret;
}
void unloadPlugin() {
DynamicPlugin::unloadPlugin();
if (_dlHandle) {
if (dlclose(_dlHandle) != 0)
warning("Failed unloading plugin '%s' (%s)", _filename.c_str(), dlerror());

View File

@ -42,11 +42,6 @@ protected:
public:
DynamicPlugin() : _metaengine(0) {}
~DynamicPlugin() {
// FIXME: The plugin has already been unloaded, so _metaengine isn't
// a valid pointer anymore, and you can't call unloadPlugin from here.
//delete _metaengine;
}
const char *getName() const {
return _metaengine->getName();
@ -88,6 +83,10 @@ public:
return true;
}
virtual void unloadPlugin() {
delete _metaengine;
}
};
#endif

View File

@ -69,6 +69,7 @@ public:
return DynamicPlugin::loadPlugin();
}
void unloadPlugin() {
DynamicPlugin::unloadPlugin();
if (_dlHandle) {
if (dlclose(_dlHandle) != 0)
warning("Failed unloading plugin '%s' (%s)", _filename.c_str(), dlerror());

View File

@ -70,6 +70,7 @@ public:
return DynamicPlugin::loadPlugin();
}
void unloadPlugin() {
DynamicPlugin::unloadPlugin();
if (_dlHandle) {
SDL_UnloadObject(_dlHandle);
_dlHandle = 0;

View File

@ -95,6 +95,7 @@ public:
return DynamicPlugin::loadPlugin();
}
void unloadPlugin() {
DynamicPlugin::unloadPlugin();
if (_dlHandle) {
if (!FreeLibrary((HMODULE)_dlHandle))
debug("Failed unloading plugin '%s'", _filename.c_str());