From fe8be472a91aafd401c7b72caf155f40c8eeada2 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 9 Feb 2016 16:00:38 +0100 Subject: [PATCH] + fix unit tests --- src/Gui/Application.cpp | 7 +++++++ src/Main/MainGui.cpp | 2 +- src/Mod/PartDesign/InvoluteGearFeature.py | 7 ++++--- src/Mod/PartDesign/fcgear/fcgear.py | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 23e2d81b1..c5c559d68 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -1484,11 +1484,18 @@ static void init_resources() void Application::initApplication(void) { + static bool init = false; + if (init) { + Base::Console().Error("Tried to run Gui::Application::initApplication() twice!\n"); + return; + } + try { initTypes(); new Base::ScriptProducer( "FreeCADGuiInit", FreeCADGuiInit ); init_resources(); old_qtmsg_handler = qInstallMsgHandler(messageHandler); + init = true; } catch (...) { // force to flush the log diff --git a/src/Main/MainGui.cpp b/src/Main/MainGui.cpp index 4ea339dfe..0a681a1c5 100644 --- a/src/Main/MainGui.cpp +++ b/src/Main/MainGui.cpp @@ -240,7 +240,7 @@ int main( int argc, char ** argv ) exit(0); } catch (const Base::Exception& e) { - Base::Console().Error("%s\n", e.what()); + e.ReportException(); } catch (...) { Base::Console().Error("Application unexpectedly terminated\n"); diff --git a/src/Mod/PartDesign/InvoluteGearFeature.py b/src/Mod/PartDesign/InvoluteGearFeature.py index 6d346fed4..d068dfa65 100644 --- a/src/Mod/PartDesign/InvoluteGearFeature.py +++ b/src/Mod/PartDesign/InvoluteGearFeature.py @@ -39,7 +39,8 @@ def makeInvoluteGear(name): '''makeInvoluteGear(name): makes an InvoluteGear''' obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython",name) _InvoluteGear(obj) - _ViewProviderInvoluteGear(obj.ViewObject) + if FreeCAD.GuiUp: + _ViewProviderInvoluteGear(obj.ViewObject) #FreeCAD.ActiveDocument.recompute() return obj @@ -243,5 +244,5 @@ class _InvoluteGearTaskPanel: FreeCADGui.ActiveDocument.resetEdit() - -FreeCADGui.addCommand('PartDesign_InvoluteGear',_CommandInvoluteGear()) +if FreeCAD.GuiUp: + FreeCADGui.addCommand('PartDesign_InvoluteGear',_CommandInvoluteGear()) diff --git a/src/Mod/PartDesign/fcgear/fcgear.py b/src/Mod/PartDesign/fcgear/fcgear.py index 02805169f..96630d7c3 100644 --- a/src/Mod/PartDesign/fcgear/fcgear.py +++ b/src/Mod/PartDesign/fcgear/fcgear.py @@ -17,7 +17,7 @@ from math import cos, sin, pi, acos, asin, atan, sqrt -import FreeCAD, FreeCADGui, Part +import FreeCAD, Part from FreeCAD import Base, Console import involute reload(involute)