X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPyInterp%2FPyInterp_Interp.cxx;h=48c6a8eb5b5a2e415f0d7a90e9031ce9f788a40d;hb=e6caa123c65e3c4a3017364ec5bb4225fd898465;hp=f76c3c69ef7d4f64b7a10e75368982a43567f641;hpb=10c11886e66ffefb2256d55ecf6485aaaef6d1d8;p=modules%2Fgui.git diff --git a/src/PyInterp/PyInterp_Interp.cxx b/src/PyInterp/PyInterp_Interp.cxx index f76c3c69e..48c6a8eb5 100644 --- a/src/PyInterp/PyInterp_Interp.cxx +++ b/src/PyInterp/PyInterp_Interp.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -293,7 +293,10 @@ bool PyInterp_Interp::initContext() _global_context = PyModule_GetDict(m); // get interpreter global variable context Py_INCREF(_global_context); _local_context = _global_context; - return true; + + int ret = PyRun_SimpleString("import salome_iapp;salome_iapp.IN_SALOME_GUI=True"); + + return ret == 0; } /*! @@ -412,7 +415,9 @@ static int compile_command(const char *command, PyObject * global_ctxt, PyObject int PyInterp_Interp::run(const char *command) { beforeRun(); - return simpleRun(command); + int ret = simpleRun(command); + afterRun(); + return ret; } /** @@ -424,6 +429,15 @@ int PyInterp_Interp::beforeRun() return 0; } +/** + * Called after a command is run (when calling run() method). Not thread-safe. Caller's responsability + * to acquire GIL if needed. + */ +int PyInterp_Interp::afterRun() +{ + return 0; +} + /*! \brief Run Python command (used internally). Not thread-safe. GIL acquisition is caller's responsability. \param command Python command