@@ -51,8 +51,21 @@ PythonQtValueStorage<qint64, 128> PythonQtConv::global_valueStorage;
51
51
PythonQtValueStorage<void *, 128 > PythonQtConv::global_ptrStorage;
52
52
PythonQtValueStorageWithCleanup<QVariant, 128 > PythonQtConv::global_variantStorage;
53
53
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
+ }
56
69
57
70
PyObject* PythonQtConv::GetPyBool (bool val)
58
71
{
@@ -103,7 +116,7 @@ PyObject* PythonQtConv::ConvertQtValueToPython(const PythonQtMethodInfo::Paramet
103
116
104
117
if (info.typeId >= QMetaType::User) {
105
118
// if a converter is registered, we use is:
106
- PythonQtConvertMetaTypeToPythonCB* converter = _metaTypeToPythonConverters. value (info.typeId );
119
+ PythonQtConvertMetaTypeToPythonCB* converter = GetMetaTypeToPythonConverters ()-> value (info.typeId );
107
120
if (converter) {
108
121
return (*converter)(info.pointerCount ==0 ?data:*((void **)data), info.typeId );
109
122
}
@@ -668,7 +681,7 @@ void* PythonQtConv::ConvertPythonToQt(const PythonQtMethodInfo::ParameterInfo& i
668
681
// We only do this for registered type > QMetaType::User for performance reasons.
669
682
if (info.typeId >= QMetaType::User) {
670
683
// 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 );
672
685
if (converter) {
673
686
if (!alreadyAllocatedCPPObject) {
674
687
// create a new empty variant of concrete type:
@@ -1174,7 +1187,7 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type)
1174
1187
} else if (type >= QVariant::UserType) {
1175
1188
// not an instance wrapper, but there might be other converters
1176
1189
// Maybe we have a special converter that is registered for that type:
1177
- PythonQtConvertPythonToMetaTypeCB* converter = _pythonToMetaTypeConverters. value (type);
1190
+ PythonQtConvertPythonToMetaTypeCB* converter = GetPythonToMetaTypeConverters ()-> value (type);
1178
1191
if (converter) {
1179
1192
// allocate a default object of the needed type:
1180
1193
v = QVariant (type, (const void *)NULL );
0 commit comments