diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 7782da5cf2..cf8afcb7ec 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -1006,6 +1006,8 @@ bool Application::activateWorkbench(const char* name) type = result.as_std_string("ascii"); if (Base::Type::fromName(type.c_str()).isDerivedFrom(Gui::PythonBaseWorkbench::getClassTypeId())) { Workbench* wb = WorkbenchManager::instance()->createWorkbench(name, type); + if (!wb) + throw Py::RuntimeError("Failed to instantiate workbench of type " + type); handler.setAttr(std::string("__Workbench__"), Py::Object(wb->getPyObject(), true)); } diff --git a/src/Gui/Workbench.cpp b/src/Gui/Workbench.cpp index 700d29b63e..ca6ffea1c1 100644 --- a/src/Gui/Workbench.cpp +++ b/src/Gui/Workbench.cpp @@ -789,7 +789,7 @@ ToolBarItem* TestWorkbench::setupCommandBars() const // ----------------------------------------------------------------------- -TYPESYSTEM_SOURCE(Gui::PythonBaseWorkbench, Gui::Workbench) +TYPESYSTEM_SOURCE_ABSTRACT(Gui::PythonBaseWorkbench, Gui::Workbench) PythonBaseWorkbench::PythonBaseWorkbench() : _menuBar(0), _contextMenu(0), _toolBar(0), _commandBar(0), _workbenchPy(0) @@ -858,10 +858,13 @@ void PythonBaseWorkbench::appendMenu(const std::list& menu, const s MenuItem* item = _menuBar->findItem( *jt ); if (!item) { - Gui::MenuItem* wnd = _menuBar->findItem( "&Windows" ); item = new MenuItem; item->setCommand( *jt ); - _menuBar->insertItem( wnd, item ); + Gui::MenuItem* wnd = _menuBar->findItem( "&Windows" ); + if (wnd) + _menuBar->insertItem(wnd, item); + else + _menuBar->appendItem(item); } // create sub menus