Lock the gil on some hand written code to avoid crashes.
Reviewer: Renato Araújo <renato.filho@openbossa.org>
Marcelo Lira <marcelo.lira@openbossa.org>
This commit is contained in:
parent
f7fd9277f4
commit
aa305dc5ae
2 changed files with 10 additions and 4 deletions
|
|
@ -650,13 +650,13 @@
|
||||||
// Define a global variable to handle qInstallMsgHandler callback
|
// Define a global variable to handle qInstallMsgHandler callback
|
||||||
static PyObject* qtmsghandler = 0;
|
static PyObject* qtmsghandler = 0;
|
||||||
|
|
||||||
void
|
static void msgHandlerCallback(QtMsgType type, const char* msg)
|
||||||
msghandlercallback(QtMsgType type, const char* msg)
|
|
||||||
{
|
{
|
||||||
|
Shiboken::GilState state;
|
||||||
Shiboken::AutoDecRef arglist(Shiboken::makeTuple(type, msg));
|
Shiboken::AutoDecRef arglist(Shiboken::makeTuple(type, msg));
|
||||||
Shiboken::AutoDecRef ret(PyObject_CallObject(qtmsghandler, arglist));
|
Shiboken::AutoDecRef ret(PyObject_CallObject(qtmsghandler, arglist));
|
||||||
}
|
}
|
||||||
void QtCoreModuleExit()
|
static void QtCoreModuleExit()
|
||||||
{
|
{
|
||||||
PySide::SignalManager::instance().clear();
|
PySide::SignalManager::instance().clear();
|
||||||
}
|
}
|
||||||
|
|
@ -673,7 +673,7 @@
|
||||||
%PYARG_0 = qtmsghandler ? qtmsghandler : Py_None;
|
%PYARG_0 = qtmsghandler ? qtmsghandler : Py_None;
|
||||||
Py_INCREF(%PYARG_1);
|
Py_INCREF(%PYARG_1);
|
||||||
qtmsghandler = %PYARG_1;
|
qtmsghandler = %PYARG_1;
|
||||||
qInstallMsgHandler(msghandlercallback);
|
qInstallMsgHandler(msgHandlerCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (%PYARG_0 == Py_None)
|
if (%PYARG_0 == Py_None)
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
// shiboken
|
// shiboken
|
||||||
#include <typeresolver.h>
|
#include <typeresolver.h>
|
||||||
|
#include <gilstate.h>
|
||||||
#include <sbkdbg.h>
|
#include <sbkdbg.h>
|
||||||
// pyside
|
// pyside
|
||||||
#include <pyside.h>
|
#include <pyside.h>
|
||||||
|
|
@ -63,6 +64,7 @@ struct ElementFactoryBase
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&nextQmlElementMutex);
|
QMutexLocker locker(&nextQmlElementMutex);
|
||||||
PySide::nextQmlElementMemoryAddr = memory;
|
PySide::nextQmlElementMemoryAddr = memory;
|
||||||
|
Shiboken::GilState state;
|
||||||
PyObject* obj = PyObject_CallObject(pyTypes[N], 0);
|
PyObject* obj = PyObject_CallObject(pyTypes[N], 0);
|
||||||
if (!obj || PyErr_Occurred())
|
if (!obj || PyErr_Occurred())
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
|
|
@ -246,6 +248,7 @@ PyTypeObject PropertyListType = {
|
||||||
// Implementation of QDeclarativeListProperty<T>::AppendFunction callback
|
// Implementation of QDeclarativeListProperty<T>::AppendFunction callback
|
||||||
void propListAppender(QDeclarativeListProperty<QDeclarativeItem>* propList, QDeclarativeItem* item)
|
void propListAppender(QDeclarativeListProperty<QDeclarativeItem>* propList, QDeclarativeItem* item)
|
||||||
{
|
{
|
||||||
|
Shiboken::GilState state;
|
||||||
Shiboken::AutoDecRef args(Shiboken::makeTuple(propList->object, item));
|
Shiboken::AutoDecRef args(Shiboken::makeTuple(propList->object, item));
|
||||||
|
|
||||||
DeclarativeListProperty* data = reinterpret_cast<DeclarativeListProperty*>(propList->data);
|
DeclarativeListProperty* data = reinterpret_cast<DeclarativeListProperty*>(propList->data);
|
||||||
|
|
@ -258,6 +261,7 @@ void propListAppender(QDeclarativeListProperty<QDeclarativeItem>* propList, QDec
|
||||||
// Implementation of QDeclarativeListProperty<T>::CountFunction callback
|
// Implementation of QDeclarativeListProperty<T>::CountFunction callback
|
||||||
int propListCount(QDeclarativeListProperty<QDeclarativeItem>* propList)
|
int propListCount(QDeclarativeListProperty<QDeclarativeItem>* propList)
|
||||||
{
|
{
|
||||||
|
Shiboken::GilState state;
|
||||||
Shiboken::AutoDecRef args(Shiboken::makeTuple(propList->object));
|
Shiboken::AutoDecRef args(Shiboken::makeTuple(propList->object));
|
||||||
|
|
||||||
DeclarativeListProperty* data = reinterpret_cast<DeclarativeListProperty*>(propList->data);
|
DeclarativeListProperty* data = reinterpret_cast<DeclarativeListProperty*>(propList->data);
|
||||||
|
|
@ -275,6 +279,7 @@ int propListCount(QDeclarativeListProperty<QDeclarativeItem>* propList)
|
||||||
// Implementation of QDeclarativeListProperty<T>::AtFunction callback
|
// Implementation of QDeclarativeListProperty<T>::AtFunction callback
|
||||||
QDeclarativeItem* propListAt(QDeclarativeListProperty<QDeclarativeItem>* propList, int index)
|
QDeclarativeItem* propListAt(QDeclarativeListProperty<QDeclarativeItem>* propList, int index)
|
||||||
{
|
{
|
||||||
|
Shiboken::GilState state;
|
||||||
Shiboken::AutoDecRef args(Shiboken::makeTuple(propList->object, index));
|
Shiboken::AutoDecRef args(Shiboken::makeTuple(propList->object, index));
|
||||||
|
|
||||||
DeclarativeListProperty* data = reinterpret_cast<DeclarativeListProperty*>(propList->data);
|
DeclarativeListProperty* data = reinterpret_cast<DeclarativeListProperty*>(propList->data);
|
||||||
|
|
@ -291,6 +296,7 @@ QDeclarativeItem* propListAt(QDeclarativeListProperty<QDeclarativeItem>* propLis
|
||||||
// Implementation of QDeclarativeListProperty<T>::ClearFunction callback
|
// Implementation of QDeclarativeListProperty<T>::ClearFunction callback
|
||||||
void propListClear(QDeclarativeListProperty<QDeclarativeItem>* propList)
|
void propListClear(QDeclarativeListProperty<QDeclarativeItem>* propList)
|
||||||
{
|
{
|
||||||
|
Shiboken::GilState state;
|
||||||
Shiboken::AutoDecRef args(Shiboken::makeTuple(propList->object));
|
Shiboken::AutoDecRef args(Shiboken::makeTuple(propList->object));
|
||||||
|
|
||||||
DeclarativeListProperty* data = reinterpret_cast<DeclarativeListProperty*>(propList->data);
|
DeclarativeListProperty* data = reinterpret_cast<DeclarativeListProperty*>(propList->data);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue