]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Proper handling of Python's GIL by SWIG
authorSergey BELASH <belash.sergey@opencascade.com>
Mon, 17 Nov 2014 14:43:00 +0000 (17:43 +0300)
committerSergey BELASH <belash.sergey@opencascade.com>
Mon, 17 Nov 2014 14:43:00 +0000 (17:43 +0300)
src/Config/Config_ModuleReader.cpp
src/GeomAPI/CMakeLists.txt
src/ModelAPI/CMakeLists.txt

index 5fec456ad65d6b8a887af6500a85a2ead56ed5da..83b16f27d5afe166f58d15d66e602cb4a6b8a494 100644 (file)
@@ -14,6 +14,7 @@
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 
+// Have to be included before std headers
 #include <Python.h>
 
 //Necessary for cerr
@@ -134,13 +135,9 @@ void Config_ModuleReader::loadPlugin(const std::string thePluginName)
 void Config_ModuleReader::loadScript(const std::string theFileName)
 {
   std::string aPythonFile = theFileName + ".py";
-  PyGILState_STATE gstate;
-
   /* aquire python thread */
-  gstate = PyGILState_Ensure();
-
+  PyGILState_STATE gstate = PyGILState_Ensure();
   PyObject* module = PyImport_ImportModule(aPythonFile.c_str());
-
   /* release python thread */
   PyGILState_Release(gstate);
 }
index c49ab5a06b3f543b9d1a61412e4e9e000c9e88c2..9ee8694c8cac79d3c34eeac641b6c7a16f4d98c2 100644 (file)
@@ -58,7 +58,7 @@ SET(PROJECT_LIBRARIES
 ADD_DEFINITIONS(-DGEOMAPI_EXPORTS ${CAS_DEFINITIONS})
 ADD_LIBRARY(GeomAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
 
-SET(CMAKE_SWIG_FLAGS "-Wall")
+SET(CMAKE_SWIG_FLAGS -threads -Wall)
 
 SET_SOURCE_FILES_PROPERTIES(GeomAPI.i PROPERTIES CPLUSPLUS ON)
 SET_SOURCE_FILES_PROPERTIES(GeomAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
index 54c0b472d50b63e5ab420220f97435c5950fbb76..149a7fe8ac929b6021319b8bf0248a85453377fd 100644 (file)
@@ -46,8 +46,7 @@ SET(PROJECT_SOURCES
 SET(PROJECT_LIBRARIES
     Config
 )
-
-SET(CMAKE_SWIG_FLAGS "-Wall")
+SET(CMAKE_SWIG_FLAGS -threads -Wall)
 ADD_DEFINITIONS(-DMODELAPI_EXPORTS -DSWIG_TYPE_TABLE=ModelAPI)
 
 ADD_LIBRARY(ModelAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})