Commit eab7c0be authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

FIXED warning when two component extensions fight to manage the same file extension

Previously there was no message at all. This means that the most global component
extension took silently the place of a local component extension.
The expected behaviour is to at least say something about this situation.
Being silent in this case can be considered as bad behaviour!
parent 414196cd
......@@ -196,18 +196,31 @@ bool ExtensionManager::loadExtension(ExtensionManager::ExtensionType type, QStri
cp->setLocation(fileName);
cp->initResources();
// count how many specific extension were inserted
int extCount = 0;
//-- insert the ComponentExtension plugin in the application wide list
if (cp->hasDataDirectory()) {
getDataDirectoryComponentExtensionMap().insert(cp->getName(), cp);
extCount++;
}
else {
// (cannot do that in the constructor because the virtual symbol table seems to be confused!)
foreach(QString ext, cp->getFileExtensions()) {
getComponentExtensionMap().insert(ext, cp);
ComponentExtension* existingComponentExtension = getComponentExtensionMap().value(ext);
if (existingComponentExtension != nullptr) {
CAMITK_INFO("ExtensionManager", "loadExtension", "Warning: duplicate extension management: component extension \"" << cp->getName().toStdString() << "\" (in file \"" << fileName.toStdString() << "\") declares management of \"" << ext.toStdString() << "\" file extension while \"" << existingComponentExtension->getName().toStdString() << "\" extension (loaded from file \"" << existingComponentExtension->getLocation().toStdString() << "\") is already managing \"" << ext.toStdString() << "\".\nUsing extension in " << existingComponentExtension->getLocation().toStdString() << " instead (higher priority) as only one component extension can manage a give file extension.");
}
else {
getComponentExtensionMap().insert(ext, cp);
extCount++;
}
}
}
returnValue = true;
// if the component only declared an extension that was already managed
// then the component was loaded but is not valid
returnValue = (extCount > 0);
}
}
break;
......
Supports Markdown
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