- Fixed plugin interface. Now both plugins are loaded. Not tried calling the exported functions, though...
- To make sure libraries are not loaded multiple times, only .so files are considered. Beware that this is not portable git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@731 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
f181c93527
commit
45cc6733e4
5 changed files with 70 additions and 73 deletions
|
@ -27,6 +27,8 @@
|
|||
#include "singleton.tcc"
|
||||
|
||||
#include <glibmm/fileutils.h>
|
||||
#include <glibmm/pattern.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace sgpem;
|
||||
|
@ -52,35 +54,41 @@ PluginManager::rescan_dirs()
|
|||
GlobalPreferences& prefs = GlobalPreferences::get_instance();
|
||||
GlobalPreferences::dir_iterator it = prefs.modules_dir_begin();
|
||||
|
||||
Glib::PatternSpec shared_obj("*.so");
|
||||
|
||||
while(it != prefs.modules_dir_end())
|
||||
{
|
||||
Glib::Dir dir(*it);
|
||||
|
||||
for(Glib::DirIterator dir_it = dir.begin(); dir_it != dir.end(); ++dir_it)
|
||||
{
|
||||
std::string module_path = Module::build_path(*it, *dir_it);
|
||||
|
||||
std::cout << "Attempting to load module at path " << module_path << std::endl;
|
||||
|
||||
try
|
||||
// only attempt to load .so files
|
||||
if(shared_obj.match(*dir_it))
|
||||
{
|
||||
module = new Module(module_path);
|
||||
std::string module_path = Module::build_path(*it, *dir_it);
|
||||
|
||||
if(*module)
|
||||
std::cout << "Attempting to load module at path " << module_path << std::endl;
|
||||
|
||||
try
|
||||
{
|
||||
_modules.push_back(module);
|
||||
std::cerr << "\tSuccess" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "\tFailed: " << Glib::Module::get_last_error() << std::endl;
|
||||
delete module;
|
||||
}
|
||||
module = new Module(module_path);
|
||||
|
||||
}
|
||||
catch(InvalidPluginException e)
|
||||
{
|
||||
std::cerr << "\tFailed, invalid plugin: " << e.what() << std::endl;
|
||||
if(*module)
|
||||
{
|
||||
_modules.push_back(module);
|
||||
std::cerr << "\tSuccess" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "\tFailed: " << Glib::Module::get_last_error() << std::endl;
|
||||
delete module;
|
||||
}
|
||||
|
||||
}
|
||||
catch(InvalidPluginException e)
|
||||
{
|
||||
std::cerr << "\tFailed, invalid plugin: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue