@@ -51,8 +51,21 @@ PythonQtValueStorage<qint64, 128> PythonQtConv::global_valueStorage;
5151PythonQtValueStorage<void *, 128 > PythonQtConv::global_ptrStorage;
5252PythonQtValueStorageWithCleanup<QVariant, 128 > PythonQtConv::global_variantStorage;
5353
54- QHash<int , PythonQtConvertMetaTypeToPythonCB*> PythonQtConv::_metaTypeToPythonConverters;
55- QHash<int , PythonQtConvertPythonToMetaTypeCB*> PythonQtConv::_pythonToMetaTypeConverters;
54+ QHash<int , PythonQtConvertMetaTypeToPythonCB*>* PythonQtConv::GetMetaTypeToPythonConverters () {
55+ static QHash<int , PythonQtConvertMetaTypeToPythonCB*>* _metaTypeToPythonConverters = nullptr ;
56+ if (_metaTypeToPythonConverters == nullptr ) {
57+ _metaTypeToPythonConverters = new QHash<int , PythonQtConvertMetaTypeToPythonCB*>();
58+ }
59+ return _metaTypeToPythonConverters;
60+ }
61+
62+ QHash<int , PythonQtConvertPythonToMetaTypeCB*>* PythonQtConv::GetPythonToMetaTypeConverters () {
63+ static QHash<int , PythonQtConvertPythonToMetaTypeCB*>* _pythonToMetaTypeConverters = nullptr ;
64+ if (_pythonToMetaTypeConverters == nullptr ) {
65+ _pythonToMetaTypeConverters = new QHash<int , PythonQtConvertPythonToMetaTypeCB*>();
66+ }
67+ return _pythonToMetaTypeConverters;
68+ }
5669
5770PyObject* PythonQtConv::GetPyBool (bool val)
5871{
@@ -103,7 +116,7 @@ PyObject* PythonQtConv::ConvertQtValueToPython(const PythonQtMethodInfo::Paramet
103116
104117 if (info.typeId >= QMetaType::User) {
105118 // if a converter is registered, we use is:
106- PythonQtConvertMetaTypeToPythonCB* converter = _metaTypeToPythonConverters. value (info.typeId );
119+ PythonQtConvertMetaTypeToPythonCB* converter = GetMetaTypeToPythonConverters ()-> value (info.typeId );
107120 if (converter) {
108121 return (*converter)(info.pointerCount ==0 ?data:*((void **)data), info.typeId );
109122 }
@@ -254,7 +267,7 @@ PyObject* PythonQtConv::convertQtValueToPythonInternal(int type, const void* dat
254267 default :
255268 // check if we have a QList of pointers, which we can circumvent with a QList<void*>
256269 if (info.isQList && (info.innerNamePointerCount == 1 )) {
257- static int id = QMetaType::type (" QList<void*>" );
270+ int id = QMetaType::type (" QList<void*>" );
258271 PythonQtValueStorage_ADD_VALUE (global_variantStorage, QVariant, QVariant::Type (id), ptr);
259272 // return the constData pointer that will be filled with the result value later on
260273 ptr = (void *)((QVariant*)ptr)->constData ();
@@ -295,13 +308,13 @@ void* PythonQtConv::handlePythonToQtAutoConversion(int typeId, PyObject* obj, vo
295308{
296309 void * ptr = alreadyAllocatedCPPObject;
297310
298- static int penId = QMetaType::type (" QPen" );
299- static int brushId = QMetaType::type (" QBrush" );
300- static int cursorId = QMetaType::type (" QCursor" );
301- static int colorId = QMetaType::type (" QColor" );
302- static PyObject* qtGlobalColorEnum = PythonQtClassInfo::findEnumWrapper (" Qt::GlobalColor" , NULL );
311+ int penId = QMetaType::type (" QPen" );
312+ int brushId = QMetaType::type (" QBrush" );
313+ int cursorId = QMetaType::type (" QCursor" );
314+ int colorId = QMetaType::type (" QColor" );
315+ PyObject* qtGlobalColorEnum = PythonQtClassInfo::findEnumWrapper (" Qt::GlobalColor" , NULL );
303316 if (typeId == cursorId) {
304- static PyObject* qtCursorShapeEnum = PythonQtClassInfo::findEnumWrapper (" Qt::CursorShape" , NULL );
317+ PyObject* qtCursorShapeEnum = PythonQtClassInfo::findEnumWrapper (" Qt::CursorShape" , NULL );
305318 if ((PyObject*)obj->ob_type == qtCursorShapeEnum) {
306319 Qt::CursorShape val = (Qt::CursorShape)PyInt_AsLong (obj);
307320 if (!ptr) {
@@ -313,7 +326,7 @@ void* PythonQtConv::handlePythonToQtAutoConversion(int typeId, PyObject* obj, vo
313326 }
314327 } else if (typeId == penId) {
315328 // brushes can be created from QColor and from Qt::GlobalColor (and from brushes, but that's the default)
316- static PyObject* qtColorClass = PythonQt::priv ()->getClassInfo (" QColor" )->pythonQtClassWrapper ();
329+ PyObject* qtColorClass = PythonQt::priv ()->getClassInfo (" QColor" )->pythonQtClassWrapper ();
317330 if ((PyObject*)obj->ob_type == qtGlobalColorEnum) {
318331 Qt::GlobalColor val = (Qt::GlobalColor)PyInt_AsLong (obj);
319332 if (!ptr) {
@@ -332,7 +345,7 @@ void* PythonQtConv::handlePythonToQtAutoConversion(int typeId, PyObject* obj, vo
332345 }
333346 } else if (typeId == brushId) {
334347 // brushes can be created from QColor and from Qt::GlobalColor (and from brushes, but that's the default)
335- static PyObject* qtColorClass = PythonQt::priv ()->getClassInfo (" QColor" )->pythonQtClassWrapper ();
348+ PyObject* qtColorClass = PythonQt::priv ()->getClassInfo (" QColor" )->pythonQtClassWrapper ();
336349 if ((PyObject*)obj->ob_type == qtGlobalColorEnum) {
337350 Qt::GlobalColor val = (Qt::GlobalColor)PyInt_AsLong (obj);
338351 if (!ptr) {
@@ -649,7 +662,7 @@ void* PythonQtConv::ConvertPythonToQt(const PythonQtMethodInfo::ParameterInfo& i
649662 if (info.typeId == PythonQtMethodInfo::Unknown || info.typeId >= QMetaType::User) {
650663 // check for QList<AnyPtr*> case, where we will use a QList<void*> QVariant
651664 if (info.isQList && (info.innerNamePointerCount == 1 )) {
652- static int id = QMetaType::type (" QList<void*>" );
665+ int id = QMetaType::type (" QList<void*>" );
653666 if (!alreadyAllocatedCPPObject) {
654667 PythonQtValueStorage_ADD_VALUE_IF_NEEDED (alreadyAllocatedCPPObject, global_variantStorage, QVariant, QVariant::Type (id), ptr);
655668 ptr = (void *)((QVariant*)ptr)->constData ();
@@ -668,7 +681,7 @@ void* PythonQtConv::ConvertPythonToQt(const PythonQtMethodInfo::ParameterInfo& i
668681 // We only do this for registered type > QMetaType::User for performance reasons.
669682 if (info.typeId >= QMetaType::User) {
670683 // Maybe we have a special converter that is registered for that type:
671- PythonQtConvertPythonToMetaTypeCB* converter = _pythonToMetaTypeConverters. value (info.typeId );
684+ PythonQtConvertPythonToMetaTypeCB* converter = GetPythonToMetaTypeConverters ()-> value (info.typeId );
672685 if (converter) {
673686 if (!alreadyAllocatedCPPObject) {
674687 // create a new empty variant of concrete type:
@@ -1174,7 +1187,7 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type)
11741187 } else if (type >= QVariant::UserType) {
11751188 // not an instance wrapper, but there might be other converters
11761189 // Maybe we have a special converter that is registered for that type:
1177- PythonQtConvertPythonToMetaTypeCB* converter = _pythonToMetaTypeConverters. value (type);
1190+ PythonQtConvertPythonToMetaTypeCB* converter = GetPythonToMetaTypeConverters ()-> value (type);
11781191 if (converter) {
11791192 // allocate a default object of the needed type:
11801193 v = QVariant (type, (const void *)NULL );
0 commit comments