Mod/Complete: Check for modules at runtime.This fixes runtime errors if e. g. TestGui isn't installed due to -DBUILD_TEST=OFF ...
This commit is contained in:
committed by
wmayer
parent
b63c5d0e04
commit
4ef4369d09
@@ -36,6 +36,8 @@
|
||||
#include <Mod/Complete/App/CompleteConfiguration.h>
|
||||
|
||||
|
||||
QList<QString> mods;
|
||||
|
||||
// use a different name to CreateCommand()
|
||||
void CreateCompleteCommands(void);
|
||||
|
||||
@@ -59,30 +61,25 @@ void CompleteGuiExport initCompleteGui()
|
||||
return;
|
||||
}
|
||||
|
||||
// load dependent module
|
||||
try {
|
||||
Base::Interpreter().loadModule("PartGui");
|
||||
Base::Interpreter().loadModule("MeshGui");
|
||||
try {
|
||||
Base::Interpreter().loadModule("MeshPartGui");
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Base::Console().Error("Failed to load MeshPartGui: %s\n", e.what());
|
||||
PyErr_Clear();
|
||||
}
|
||||
Base::Interpreter().loadModule("PointsGui");
|
||||
//Base::Interpreter().loadModule("MeshPartGui");
|
||||
//Base::Interpreter().loadModule("AssemblyGui");
|
||||
Base::Interpreter().loadModule("DrawingGui");
|
||||
Base::Interpreter().loadModule("RaytracingGui");
|
||||
# ifdef COMPLETE_SHOW_SKETCHER
|
||||
Base::Interpreter().loadModule("SketcherGui");
|
||||
# endif
|
||||
Base::Interpreter().loadModule("PartDesignGui");
|
||||
Base::Interpreter().loadModule("ImageGui");
|
||||
//Base::Interpreter().loadModule("CamGui");
|
||||
Base::Interpreter().loadModule("TestGui");
|
||||
# ifdef COMPLETE_USE_DRAFTING
|
||||
// try to load dependent modules, currently not (AssemblyGui, CamGui)
|
||||
char *modules[] = {"PartGui", "MeshGui", "MeshPartGui", "PointsGui", "DrawingGui", "RaytracingGui", "SketcherGui", "PartDesignGui", "ImageGui", "TestGui"};
|
||||
char nModules = sizeof(modules) / sizeof(char*);
|
||||
for (char i = 0; i < nModules; i++) {
|
||||
try {
|
||||
Base::Interpreter().loadModule(modules[i]);
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
// Prints message to console window if we are in interactive mode
|
||||
PyErr_Print();
|
||||
continue;
|
||||
}
|
||||
mods.append(QSTRING(modules[i]));
|
||||
}
|
||||
|
||||
# ifdef COMPLETE_USE_DRAFTING
|
||||
mods.append(QSTRING("DraftGui"));
|
||||
try {
|
||||
Py::Module module(PyImport_ImportModule("FreeCADGui"),true);
|
||||
Py::Callable method(module.getAttr(std::string("getWorkbench")));
|
||||
|
||||
@@ -110,25 +107,14 @@ void CompleteGuiExport initCompleteGui()
|
||||
|
||||
// Get the CompleteWorkbench handler
|
||||
args.setItem(0,Py::String("CompleteWorkbench"));
|
||||
# endif
|
||||
}
|
||||
catch(const Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_ImportError, e.what());
|
||||
return;
|
||||
}
|
||||
catch (Py::Exception& e) {
|
||||
Py::Object o = Py::type(e);
|
||||
if (o.isString()) {
|
||||
Py::String s(o);
|
||||
Base::Console().Error("%s\n", s.as_std_string("utf-8").c_str());
|
||||
}
|
||||
else {
|
||||
Py::String s(o.repr());
|
||||
Base::Console().Error("%s\n", s.as_std_string("utf-8").c_str());
|
||||
}
|
||||
// Prints message to console window if we are in interactive mode
|
||||
PyErr_Print();
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
mods.removeAt(mods.size());
|
||||
// Prints message to console window if we are in interactive mode
|
||||
PyErr_Print();
|
||||
}
|
||||
# endif
|
||||
|
||||
(void) Py_InitModule("CompleteGui", CompleteGui_Import_methods); /* mod name, table ptr */
|
||||
Base::Console().Log("Loading GUI of Complete module... done\n");
|
||||
|
||||
Reference in New Issue
Block a user