PIPluginLoader lib lastError

This commit is contained in:
2020-10-18 12:00:52 +03:00
parent d0ef71c933
commit 6d7da02de6
2 changed files with 13 additions and 3 deletions

View File

@@ -217,7 +217,10 @@ PIPluginLoader::~PIPluginLoader() {
bool PIPluginLoader::load(const PIString & name) {
unload();
if (!lib.load(findLibrary(name))) return false;
if (!lib.load(findLibrary(name))) {
piCout << "Load plugin \"" << name << "\"load failed with error: " << lib.lastError().trimmed();
return false;
}
//piCout << "loading" << lib.path() << "...";
func_loader_version = (FunctionLoaderVersion)lib.resolve(STR(__PIP_PLUGIN_LOADER_VERSION_FUNC__));
if (!func_loader_version) {
@@ -253,8 +256,7 @@ bool PIPluginLoader::load(const PIString & name) {
func_static_merge = (FunctionStaticMerge)lib.resolve(STR(__PIP_PLUGIN_STATIC_MERGE_FUNC__));
if (func_static_merge) {
auto pss = plugin_info->staticSections(true), lss = PIPluginInfo::instance()->staticSections(false);
piCout << lss.keys() << pss.keys();
//piCout << lss.keys() << pss.keys();
auto it = lss.makeIterator();
while (it.next()) {
if (!pss.contains(it.key()))
@@ -286,6 +288,11 @@ PIString PIPluginLoader::libPath() {
}
PIString PIPluginLoader::lastError() {
return lib.lastError();
}
void * PIPluginLoader::resolve(const char * name) {
if (!loaded) return nullptr;
return lib.resolve(name);

View File

@@ -150,6 +150,9 @@ public:
//! Returns loaded plugin library path
PIString libPath();
//! Returns library lastError
PIString lastError();
//! Resolve symbol "name" from plugin library
void * resolve(const char * name);