From aa305dc5ae5f463c31938fb50cd92257b0fc7911 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 4 Jan 2011 18:46:40 -0200 Subject: Lock the gil on some hand written code to avoid crashes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Marcelo Lira --- PySide/QtCore/typesystem_core.xml | 8 ++++---- PySide/QtDeclarative/pysideqmlregistertype.cpp | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'PySide') diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 54513f951..f41acd5ca 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -650,13 +650,13 @@ // Define a global variable to handle qInstallMsgHandler callback static PyObject* qtmsghandler = 0; - void - msghandlercallback(QtMsgType type, const char* msg) + static void msgHandlerCallback(QtMsgType type, const char* msg) { + Shiboken::GilState state; Shiboken::AutoDecRef arglist(Shiboken::makeTuple(type, msg)); Shiboken::AutoDecRef ret(PyObject_CallObject(qtmsghandler, arglist)); } - void QtCoreModuleExit() + static void QtCoreModuleExit() { PySide::SignalManager::instance().clear(); } @@ -673,7 +673,7 @@ %PYARG_0 = qtmsghandler ? qtmsghandler : Py_None; Py_INCREF(%PYARG_1); qtmsghandler = %PYARG_1; - qInstallMsgHandler(msghandlercallback); + qInstallMsgHandler(msgHandlerCallback); } if (%PYARG_0 == Py_None) diff --git a/PySide/QtDeclarative/pysideqmlregistertype.cpp b/PySide/QtDeclarative/pysideqmlregistertype.cpp index 362e56d67..0b057586e 100644 --- a/PySide/QtDeclarative/pysideqmlregistertype.cpp +++ b/PySide/QtDeclarative/pysideqmlregistertype.cpp @@ -27,6 +27,7 @@ #include // shiboken #include +#include #include // pyside #include @@ -63,6 +64,7 @@ struct ElementFactoryBase { QMutexLocker locker(&nextQmlElementMutex); PySide::nextQmlElementMemoryAddr = memory; + Shiboken::GilState state; PyObject* obj = PyObject_CallObject(pyTypes[N], 0); if (!obj || PyErr_Occurred()) PyErr_Print(); @@ -246,6 +248,7 @@ PyTypeObject PropertyListType = { // Implementation of QDeclarativeListProperty::AppendFunction callback void propListAppender(QDeclarativeListProperty* propList, QDeclarativeItem* item) { + Shiboken::GilState state; Shiboken::AutoDecRef args(Shiboken::makeTuple(propList->object, item)); DeclarativeListProperty* data = reinterpret_cast(propList->data); @@ -258,6 +261,7 @@ void propListAppender(QDeclarativeListProperty* propList, QDec // Implementation of QDeclarativeListProperty::CountFunction callback int propListCount(QDeclarativeListProperty* propList) { + Shiboken::GilState state; Shiboken::AutoDecRef args(Shiboken::makeTuple(propList->object)); DeclarativeListProperty* data = reinterpret_cast(propList->data); @@ -275,6 +279,7 @@ int propListCount(QDeclarativeListProperty* propList) // Implementation of QDeclarativeListProperty::AtFunction callback QDeclarativeItem* propListAt(QDeclarativeListProperty* propList, int index) { + Shiboken::GilState state; Shiboken::AutoDecRef args(Shiboken::makeTuple(propList->object, index)); DeclarativeListProperty* data = reinterpret_cast(propList->data); @@ -291,6 +296,7 @@ QDeclarativeItem* propListAt(QDeclarativeListProperty* propLis // Implementation of QDeclarativeListProperty::ClearFunction callback void propListClear(QDeclarativeListProperty* propList) { + Shiboken::GilState state; Shiboken::AutoDecRef args(Shiboken::makeTuple(propList->object)); DeclarativeListProperty* data = reinterpret_cast(propList->data); -- cgit v1.2.3