From aee5b0213bf7ebb1d9040f306fe38e99db331884 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 12 Feb 2019 13:07:48 +0100 Subject: [PATCH] improve exception handling if module to load a file cannot be imported --- src/Gui/Application.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index bc92355d80..711404820f 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -503,11 +503,13 @@ void Application::open(const char* FileName, const char* Module) } if (Module != 0) { - // issue module loading - Command::doCommand(Command::App, "import %s", Module); try { + // issue module loading + Command::doCommand(Command::App, "import %s", Module); + // load the file with the module Command::doCommand(Command::App, "%s.open(u\"%s\")", Module, unicodepath.c_str()); + // ViewFit if (!File.hasExtension("FCStd") && sendHasMsgToActiveView("ViewFit")) { ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath @@ -515,6 +517,7 @@ void Application::open(const char* FileName, const char* Module) if (hGrp->GetBool("AutoFitToView", true)) Command::doCommand(Command::Gui, "Gui.SendMsgToActiveView(\"ViewFit\")"); } + // the original file name is required QString filename = QString::fromUtf8(File.filePath().c_str()); getMainWindow()->appendRecentFile(filename); @@ -543,10 +546,10 @@ void Application::importFrom(const char* FileName, const char* DocName, const ch string unicodepath = Base::Tools::escapedUnicodeFromUtf8(File.filePath().c_str()); if (Module != 0) { - // issue module loading - Command::doCommand(Command::App, "import %s", Module); - try { + // issue module loading + Command::doCommand(Command::App, "import %s", Module); + // load the file with the module if (File.hasExtension("FCStd")) { Command::doCommand(Command::App, "%s.open(u\"%s\")" @@ -1188,7 +1191,11 @@ bool Application::activateWorkbench(const char* name) } Base::Console().Error("%s\n", (const char*)msg.toLatin1()); - Base::Console().Error("%s\n", e.getStackTrace().c_str()); + if (!d->startingUp) + Base::Console().Error("%s\n", e.getStackTrace().c_str()); + else + Base::Console().Log("%s\n", e.getStackTrace().c_str()); + if (!d->startingUp) { wc.restoreCursor(); QMessageBox::critical(getMainWindow(), QObject::tr("Workbench failure"),