Skip to content

Commit

Permalink
bugfix: enable on-demand loading/unloading with MultiClassLoader
Browse files Browse the repository at this point in the history
- enforce loading of library in loadLibrary(), otherwise we cannot know
- don't unload libraries in destructor when on-demand-unloading is enabled
  • Loading branch information
rhaschke committed Apr 3, 2016
1 parent 8a816d7 commit f6d8ccc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions include/class_loader/multi_library_class_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class MultiLibraryClassLoader
for(unsigned int c = 0; c < active_loaders.size(); c++)
{
ClassLoader* current = active_loaders.at(c);
if (!current->isLibraryLoaded())
current->loadLibrary();
if(current->isClassAvailable<Base>(class_name))
return(current->createInstance<Base>(class_name));
}
Expand Down Expand Up @@ -113,6 +115,8 @@ class MultiLibraryClassLoader
for(unsigned int c = 0; c < active_loaders.size(); c++)
{
ClassLoader* current = active_loaders.at(c);
if (!current->isLibraryLoaded())
current->loadLibrary();
if(current->isClassAvailable<Base>(class_name))
return(current->createUnmanagedInstance<Base>(class_name));
}
Expand Down
5 changes: 4 additions & 1 deletion src/multi_library_class_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ enable_ondemand_loadunload_(enable_ondemand_loadunload)

MultiLibraryClassLoader::~MultiLibraryClassLoader()
{
shutdownAllClassLoaders();
if (!isOnDemandLoadUnloadEnabled())
shutdownAllClassLoaders(); // don't unload libs to avoid SEVERE WARNING
// TODO: free ClassLoaders in active_class_loaders_
// However, we still need them in on-demand-load-unload mode. Otherwise we risk seg-faults.
}

std::vector<std::string> MultiLibraryClassLoader::getRegisteredLibraries()
Expand Down

0 comments on commit f6d8ccc

Please sign in to comment.