+ improve autoload mechanism to get commands of custom toolbars

This commit is contained in:
wmayer 2015-12-16 21:19:12 +01:00
parent 4f2992db54
commit f958dadb69

View File

@ -277,16 +277,28 @@ void Workbench::setupCustomToolbars(ToolBarItem* root, const Base::Reference<Par
else { else {
Command* pCmd = rMgr.getCommandByName(it2->first.c_str()); Command* pCmd = rMgr.getCommandByName(it2->first.c_str());
if (!pCmd) { // unknown command if (!pCmd) { // unknown command
// try to find out the appropriate module name // first try the module name as is
std::string pyMod = it2->second + "Gui"; std::string pyMod = it2->second;
try { try {
Base::Interpreter().loadModule(pyMod.c_str()); Base::Interpreter().loadModule(pyMod.c_str());
// Try again
pCmd = rMgr.getCommandByName(it2->first.c_str());
} }
catch(const Base::Exception&) { catch(const Base::Exception&) {
} }
}
// Try again // still not there?
pCmd = rMgr.getCommandByName(it2->first.c_str()); if (!pCmd) {
// add the 'Gui' suffix
std::string pyMod = it2->second + "Gui";
try {
Base::Interpreter().loadModule(pyMod.c_str());
// Try again
pCmd = rMgr.getCommandByName(it2->first.c_str());
}
catch(const Base::Exception&) {
}
} }
if (pCmd) { if (pCmd) {