From f958dadb698f83d6ce450cf4a9decb3515740c4c Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 16 Dec 2015 21:19:12 +0100 Subject: [PATCH] + improve autoload mechanism to get commands of custom toolbars --- src/Gui/Workbench.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Gui/Workbench.cpp b/src/Gui/Workbench.cpp index a1eead34c7..f29ce1e671 100644 --- a/src/Gui/Workbench.cpp +++ b/src/Gui/Workbench.cpp @@ -277,16 +277,28 @@ void Workbench::setupCustomToolbars(ToolBarItem* root, const Base::Referencefirst.c_str()); if (!pCmd) { // unknown command - // try to find out the appropriate module name - std::string pyMod = it2->second + "Gui"; + // first try the module name as is + std::string pyMod = it2->second; try { Base::Interpreter().loadModule(pyMod.c_str()); + // Try again + pCmd = rMgr.getCommandByName(it2->first.c_str()); } catch(const Base::Exception&) { } + } - // Try again - pCmd = rMgr.getCommandByName(it2->first.c_str()); + // still not there? + 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) {