improve exception handling if module to load a file cannot be imported

This commit is contained in:
wmayer
2019-02-12 13:07:48 +01:00
parent 92716f1361
commit 6730ffebd8

View File

@@ -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"),