diff options
author | renatofilho <renato.filho@openbossa.org> | 2010-10-26 15:38:21 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:08:53 -0300 |
commit | ce8f43df969038f5e24c7923abeac2c9fa6461e0 (patch) | |
tree | d116562943ec0d5a4c69856aac7eb19ed15e61ec | |
parent | 467240696e7ed0ca03cdecffa2b63112ab9507d8 (diff) |
Release gil before call C++ function on virtual method.
Fixes bug #423.
Reviewer: Hugo Parente Lima <hugo.pl@gmail.com>
Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r-- | generator/cppgenerator.cpp | 4 | ||||
-rw-r--r-- | libshiboken/gilstate.cpp | 8 | ||||
-rw-r--r-- | libshiboken/gilstate.h | 1 |
3 files changed, 9 insertions, 4 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp index 051af21c7..fe9ea5c32 100644 --- a/generator/cppgenerator.cpp +++ b/generator/cppgenerator.cpp @@ -532,6 +532,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFu s << INDENT << "if (py_override.isNull()) {" << endl; { Indentation indentation(INDENT); + s << INDENT << "gil.release();" << endl; CodeSnipList snips; if (func->hasInjectedCode()) { @@ -554,8 +555,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFu s << INDENT << "Shiboken::ThreadStateSaver " THREAD_STATE_SAVER_VAR ";" << endl; s << INDENT << THREAD_STATE_SAVER_VAR ".save();" << endl; } - - s << INDENT << "return this->::" << func->implementingClass()->qualifiedCppName() << "::"; + s << "return this->::" << func->implementingClass()->qualifiedCppName() << "::"; writeFunctionCall(s, func, Generator::VirtualCall); } } diff --git a/libshiboken/gilstate.cpp b/libshiboken/gilstate.cpp index 50a3c6e6e..f49930e1d 100644 --- a/libshiboken/gilstate.cpp +++ b/libshiboken/gilstate.cpp @@ -33,10 +33,14 @@ GilState::GilState() GilState::~GilState() { - if(Py_IsInitialized()) - PyGILState_Release(m_gstate); + release(); } +void GilState::release() +{ + if(Py_IsInitialized() && m_gstate) + PyGILState_Release(m_gstate); +} } // namespace Shiboken diff --git a/libshiboken/gilstate.h b/libshiboken/gilstate.h index efb3cb794..b2f33cb2c 100644 --- a/libshiboken/gilstate.h +++ b/libshiboken/gilstate.h @@ -34,6 +34,7 @@ class LIBSHIBOKEN_API GilState public: GilState(); ~GilState(); + void release(); private: PyGILState_STATE m_gstate; }; |