aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrenatofilho <renato.filho@openbossa.org>2010-10-27 17:10:24 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:08:53 -0300
commit1c3869ae5c7fb4c1812200671fedcc41e3c62d5e (patch)
tree05c2af6ee669cf861901c9c5e04b4cb3e3b3caee
parenteb1bab16740473eed6150944e061df96e65321b8 (diff)
Fixed GilState and ThreadSave code generation.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Marcelo Lira <marcelo.lira@openbossa.org>
-rw-r--r--generator/cppgenerator.cpp9
-rw-r--r--libshiboken/gilstate.cpp8
-rw-r--r--libshiboken/gilstate.h1
3 files changed, 9 insertions, 9 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index fe9ea5c32..7f708d204 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -532,8 +532,6 @@ 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()) {
snips = func->injectedCodeSnips();
@@ -551,11 +549,8 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFu
s << defaultReturnExpr;
}
} else {
- if (func->allowThread()) {
- s << INDENT << "Shiboken::ThreadStateSaver " THREAD_STATE_SAVER_VAR ";" << endl;
- s << INDENT << THREAD_STATE_SAVER_VAR ".save();" << endl;
- }
- s << "return this->::" << func->implementingClass()->qualifiedCppName() << "::";
+ s << INDENT << "gil.release();" << endl;
+ s << INDENT << "return this->::" << func->implementingClass()->qualifiedCppName() << "::";
writeFunctionCall(s, func, Generator::VirtualCall);
}
}
diff --git a/libshiboken/gilstate.cpp b/libshiboken/gilstate.cpp
index f49930e1d..cc8963ff7 100644
--- a/libshiboken/gilstate.cpp
+++ b/libshiboken/gilstate.cpp
@@ -27,8 +27,10 @@ namespace Shiboken
GilState::GilState()
{
- if(Py_IsInitialized())
+ if(Py_IsInitialized()) {
m_gstate = PyGILState_Ensure();
+ m_locked = true;
+ }
}
GilState::~GilState()
@@ -38,8 +40,10 @@ GilState::~GilState()
void GilState::release()
{
- if(Py_IsInitialized() && m_gstate)
+ if(m_locked && Py_IsInitialized()) {
PyGILState_Release(m_gstate);
+ m_locked = false;
+ }
}
} // namespace Shiboken
diff --git a/libshiboken/gilstate.h b/libshiboken/gilstate.h
index b2f33cb2c..f67e69594 100644
--- a/libshiboken/gilstate.h
+++ b/libshiboken/gilstate.h
@@ -37,6 +37,7 @@ public:
void release();
private:
PyGILState_STATE m_gstate;
+ bool m_locked;
};
} // namespace Shiboken