diff --git a/src/Mod/Start/App/AppStart.cpp b/src/Mod/Start/App/AppStart.cpp index 2837c4152..0aed4b032 100644 --- a/src/Mod/Start/App/AppStart.cpp +++ b/src/Mod/Start/App/AppStart.cpp @@ -27,6 +27,7 @@ #endif #include +#include #include #include #include @@ -46,11 +47,18 @@ public: private: }; + +PyObject* initModule() +{ + return (new Module)->module().ptr(); +} + } // namespace Start /* Python entry */ -PyMODINIT_FUNC initStart() +PyMOD_INIT_FUNC(Start) { - new Start::Module(); + PyObject* mod = Start::initModule(); Base::Console().Log("Loading Start module... done\n"); + PyMOD_Return(mod); } diff --git a/src/Mod/Start/Gui/AppStartGui.cpp b/src/Mod/Start/Gui/AppStartGui.cpp index 898806f95..820a2b8ec 100644 --- a/src/Mod/Start/Gui/AppStartGui.cpp +++ b/src/Mod/Start/Gui/AppStartGui.cpp @@ -62,15 +62,21 @@ public: private: }; + +PyObject* initModule() +{ + return (new Module)->module().ptr(); +} + } // namespace StartGui /* Python entry */ -PyMODINIT_FUNC initStartGui() +PyMOD_INIT_FUNC(StartGui) { if (!Gui::Application::Instance) { PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application."); - return; + PyMOD_Return(0); } // load dependent module @@ -79,7 +85,7 @@ PyMODINIT_FUNC initStartGui() } catch(const Base::Exception& e) { PyErr_SetString(PyExc_ImportError, e.what()); - return; + PyMOD_Return(0); } catch (Py::Exception& e) { Py::Object o = Py::type(e); @@ -95,7 +101,7 @@ PyMODINIT_FUNC initStartGui() PyErr_Print(); } - new StartGui::Module(); + PyObject* mod = StartGui::initModule(); Base::Console().Log("Loading GUI of Start module... done\n"); // instantiating the commands @@ -104,4 +110,5 @@ PyMODINIT_FUNC initStartGui() // add resources and reloads the translators loadStartResource(); + PyMOD_Return(mod); }