浏览代码

Use Py_IsInitialized() instead of PyEval_ThreadsInitialized()

Since PyEval_InitThreads() hasn't been called, PyEval_ThreadsInitialized()
won't return True.

Calling PyEval_InitThreads() shouldn't be call if not needed, indeed as mention
in the documentation calling this function initialize and acquire the global
interpreter lock which cause an unnecessary overhead.
Jean-Christophe Fillion-Robin 14 年之前
父节点
当前提交
e93bbba8d8
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      Libs/Scripting/Python/Core/ctkAbstractPythonManager.cpp

+ 1 - 1
Libs/Scripting/Python/Core/ctkAbstractPythonManager.cpp

@@ -49,7 +49,7 @@ ctkAbstractPythonManager::ctkAbstractPythonManager(QObject* _parent) : Superclas
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 ctkAbstractPythonManager::~ctkAbstractPythonManager()
 ctkAbstractPythonManager::~ctkAbstractPythonManager()
 {
 {
-  if (PyEval_ThreadsInitialized())
+  if (Py_IsInitialized())
     {
     {
     PyThreadState* state = PyThreadState_Get();
     PyThreadState* state = PyThreadState_Get();
     Py_EndInterpreter(state);
     Py_EndInterpreter(state);