Commit b1bbc90a authored by Emmanuel Promayon's avatar Emmanuel Promayon

NEW improved error message when loading extension

(less text, more separators)
parent e0b006d6
......@@ -124,14 +124,18 @@ void ExtensionManager::autoload(ExtensionManager::ExtensionType type) {
QStringList errorStrings;
foreach (QString fileName, extensionAbsoluteFileNames) {
QPluginLoader pluginLoader(fileName);
QPluginLoader pluginLoader;
// from Qt doc: "causes all symbols in a library to be resolved when it is loaded, not simply when resolve() is called."
pluginLoader.setLoadHints(QLibrary::ResolveAllSymbolsHint);
pluginLoader.setFileName(fileName);
QObject* plugin = pluginLoader.instance();
if (!plugin) {
errorStrings << QString("Plugin " + fileName + ", error: " + pluginLoader.errorString());
errorStrings << QString("Plugin:\n\"" + pluginLoader.fileName() + "\"\n") << QString("Error:\n" + pluginLoader.errorString().remove(pluginLoader.fileName()).remove("(: ").remove(QRegularExpression("\\)$")) + "\n");
}
else {
errorStrings << QString("Plugin " + fileName + ", no error (you need to decrease your number of dependency level, or contact the CamiTK SDK developer team)");
errorStrings << QString("Plugin:\n\"" + pluginLoader.fileName() + "\"\n") << QString("No error (you need to increase your number of dependency level, or contact the CamiTK SDK developer team)");
}
}
......@@ -145,8 +149,13 @@ void ExtensionManager::autoload(ExtensionManager::ExtensionType type) {
osLibraryPathSeparator = ":";
#endif
CAMITK_ERROR_ALT(tr("Extension Manager Opening Error: autoLoad plugin failed after %1 tries for the following extension(s):\n - %2\nList of library paths:\n - %3\nList of path:\n - %4\n").arg(
QString::number(tryNr), errorStrings.join("\n - "), Application::instance()->libraryPaths().join("\n - "), QString(qgetenv(osLibraryPath.toStdString().c_str())).split(osLibraryPathSeparator.toStdString().c_str()).join("\n - ")))
CAMITK_ERROR_ALT(tr("Extension manager error:\nLoading %1 extension failed after %2 tries.\n\n%3\nList of library paths:\n - %4\n\nList of path:\n - %5")
.arg((type == ACTION) ? "action" : ((type == COMPONENT) ? "component" : "viewer"))
.arg(QString::number(tryNr))
.arg(errorStrings.join("\n"))
.arg(Application::instance()->libraryPaths().join("\n - "))
.arg(QString(qgetenv(osLibraryPath.toStdString().c_str())).split(osLibraryPathSeparator.toStdString().c_str()).join("\n - "))
)
}
......@@ -186,7 +195,11 @@ bool ExtensionManager::loadExtension(ExtensionManager::ExtensionType type, QStri
initPrivateLibDirs();
bool returnValue = false;
QPluginLoader pluginLoader(fileName);
QPluginLoader pluginLoader;
// from Qt doc: "causes all symbols in a library to be resolved when it is loaded, not simply when resolve() is called."
pluginLoader.setLoadHints(QLibrary::ResolveAllSymbolsHint);
pluginLoader.setFileName(fileName);
// load the plugin and get the instance
QObject* extension = pluginLoader.instance();
if (extension) {
......@@ -220,11 +233,13 @@ bool ExtensionManager::loadExtension(ExtensionManager::ExtensionType type, QStri
// check that ext is managing a new class
int i = 0;
while (i < getViewerExtensionMap().size() && getViewerExtensionsList().at(i)->getViewerClassName() != ext->getViewerClassName()) {
i++;
}
returnValue = (i >= getViewerExtensionMap().size());
if (returnValue) {
//-- register the filename
getViewerExtensionMap().insert(fileName, ext);
......@@ -482,7 +497,7 @@ bool ExtensionManager::unloadViewerExtension(QString fileName) {
Application::unregisterAllViewers(ext);
// delete extensions (and all its actions)
delete ext;
return true;
}
else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment