27#include "python/pythonWrapper.h"
30#include "../../common/sharedStructures.h"
34#include <qsharedpointer.h>
59 template<
typename _Tp>
static void deleter(_Tp *sharedPointerData)
61 auto iter = m_hashTable.find((
void*)sharedPointerData);
63 if (iter != m_hashTable.end())
65 PyObject *val = iter.value();
69 if (PyGILState_Check())
79 m_hashTable.erase(iter);
94 Py_XINCREF(pyObjOwner);
95 m_hashTable.insert((
void*)sharedPointerData, pyObjOwner);
96 return QSharedPointer<_Tp>(sharedPointerData, deleter<_Tp>);
106 static QHash<
void* , PyObject* > m_hashTable;
Guard for a shared pointer of a PyObject.
Definition pythonSharedPointerGuard.h:50
static QSharedPointer< _Tp > createPythonSharedPointer(_Tp *sharedPointerData, PyObject *pyObjOwner)
< main method to get the guarded shared pointer
Definition pythonSharedPointerGuard.h:92
static void safeDecrefPyObject2Async(PyObject *obj)
user-defined deleter for the QSharedPointer, released by createPythonSharedPointer
Definition pythonSharedPointerGuard.cpp:49
Definition apiFunctionsGraph.cpp:40