aboutsummaryrefslogtreecommitdiffstats
path: root/libshiboken
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 /libshiboken
parenteb1bab16740473eed6150944e061df96e65321b8 (diff)
Fixed GilState and ThreadSave code generation.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'libshiboken')
-rw-r--r--libshiboken/gilstate.cpp8
-rw-r--r--libshiboken/gilstate.h1
2 files changed, 7 insertions, 2 deletions
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