summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generator/cppgenerator.cpp19
1 files changed, 2 insertions, 17 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index 1c9c90fa..9d8fb79f 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -1710,8 +1710,6 @@ void CppGenerator::writeFunctionCalls(QTextStream& s, const OverloadData& overlo
s << INDENT << "{" << endl;
{
Indentation indent(INDENT);
- if (overloadData.hasAllowThread())
- s << INDENT << "Shiboken::ThreadStateSaver " THREAD_STATE_SAVER_VAR ";" << endl;
s << INDENT << (overloads.count() > 1 ? "switch (overloadId) " : "") << '{' << endl;
{
@@ -1905,9 +1903,6 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
// Used to provide contextual information to custom code writer function.
const AbstractMetaArgument* lastArg = 0;
- if (func->allowThread())
- s << INDENT << THREAD_STATE_SAVER_VAR ".save();" << endl;
-
CodeSnipList snips;
if (func->hasInjectedCode()) {
snips = func->injectedCodeSnips();
@@ -1934,9 +1929,6 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
if (convRules.size())
writeCodeSnips(s, convRules, CodeSnip::Beginning, TypeSystem::TargetLangCode, func);
- // Code to restore the threadSaver has been written?
- bool threadRestored = false;
-
if (!func->isUserAdded()) {
bool badModifications = false;
QStringList userArgs;
@@ -2108,7 +2100,7 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
}
if (!injectedCodeCallsCppFunction(func)) {
- s << INDENT;
+ s << INDENT << "PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS" << endl << INDENT;
if (isCtor) {
s << "cptr = ";
} else if (func->type() && !func->isInplaceOperator()) {
@@ -2129,11 +2121,7 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
s << " " CPP_RETURN_VAR " = ";
}
s << methodCall << ';' << endl;
-
- if (func->allowThread()) {
- s << INDENT << THREAD_STATE_SAVER_VAR ".restore();" << endl;
- threadRestored = true;
- }
+ s << INDENT << "PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS" << endl;
if (!isCtor && !func->isInplaceOperator() && func->type()) {
s << INDENT << PYTHON_RETURN_VAR " = ";
@@ -2143,9 +2131,6 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
}
}
- if (!threadRestored && func->allowThread())
- s << INDENT << THREAD_STATE_SAVER_VAR ".restore();" << endl;
-
if (func->hasInjectedCode() && !func->isConstructor()) {
s << endl;
writeCodeSnips(s, snips, CodeSnip::End, TypeSystem::TargetLangCode, func, lastArg);