Skip to content

Commit 69f59ad

Browse files
committed
chore: Consistently use QMetaType::UnknownType
1 parent 25219b8 commit 69f59ad

File tree

3 files changed

+3
-51
lines changed

3 files changed

+3
-51
lines changed

src/PythonQtConversion.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,11 +1094,7 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type)
10941094
) {
10951095
// no special type requested
10961096
if (val == nullptr) {
1097-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
1098-
type = QMetaType::UnknownType;
1099-
#else
1100-
type = 0; // Equivalent to QVariant::Invalid or unregistered type
1101-
#endif
1097+
type = QMetaType::UnknownType; // Equivalent to QVariant::Invalid or unregistered type
11021098
} else if (PyBytes_Check(val)) {
11031099
#ifdef PY3K
11041100
// In Python 3, it is a ByteArray
@@ -1148,11 +1144,7 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type)
11481144
return v;
11491145
} else if (val == Py_None) {
11501146
// none is invalid
1151-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
1152-
type = QMetaType::UnknownType;
1153-
#else
1154-
type = 0; // Equivalent to QVariant::Invalid or unregistered type
1155-
#endif
1147+
type = QMetaType::UnknownType; // Equivalent to QVariant::Invalid or unregistered type
11561148
} else if (PyDict_Check(val)) {
11571149
type = QMetaType::QVariantMap;
11581150
} else if (PyList_Check(val) || PyTuple_Check(val) || PySequence_Check(val)) {
@@ -1165,11 +1157,7 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type)
11651157
}
11661158
// special type request:
11671159
switch (type) {
1168-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
1169-
case QMetaType::UnknownType:
1170-
#else
1171-
case 0: // Equivalent to QVariant::Invalid or unregistered type
1172-
#endif
1160+
case QMetaType::UnknownType: // Equivalent to QVariant::Invalid or unregistered type
11731161
return v;
11741162
break;
11751163
case QMetaType::Int:

src/PythonQtConversion.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,7 @@ PyObject* PythonQtConvertListOfValueTypeToPythonList(const void* /*QList<T>* */
238238
{
239239
ListType* list = (ListType*)inList;
240240
static const int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId)));
241-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
242241
if (innerType == QMetaType::UnknownType) {
243-
#else
244-
if (innerType == QVariant::Invalid) {
245-
#endif
246242
std::cerr << "PythonQtConvertListOfValueTypeToPythonList: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
247243
}
248244
PyObject* result = PyTuple_New(list->size());
@@ -259,11 +255,7 @@ bool PythonQtConvertPythonListToListOfValueType(PyObject* obj, void* /*QList<T>*
259255
{
260256
ListType* list = (ListType*)outList;
261257
static const int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId)));
262-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
263258
if (innerType == QMetaType::UnknownType) {
264-
#else
265-
if (innerType == QVariant::Invalid) {
266-
#endif
267259
std::cerr << "PythonQtConvertPythonListToListOfValueType: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
268260
}
269261
bool result = false;
@@ -363,11 +355,7 @@ PyObject* PythonQtConvertPairToPython(const void* /*QPair<T1,T2>* */ inPair, int
363355
innerType1 = PythonQtUtils::metaTypeIdFromTypeName(names.at(0).trimmed());
364356
innerType2 = PythonQtUtils::metaTypeIdFromTypeName(names.at(1).trimmed());
365357
}
366-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
367358
if (innerType1 == QMetaType::UnknownType || innerType2 == QMetaType::UnknownType) {
368-
#else
369-
if (innerType1 == QVariant::Invalid || innerType2 == QVariant::Invalid) {
370-
#endif
371359
std::cerr << "PythonQtConvertPairToPython: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
372360
}
373361
PyObject* result = PyTuple_New(2);
@@ -388,11 +376,7 @@ bool PythonQtConvertPythonToPair(PyObject* obj, void* /*QPair<T1,T2>* */ outPair
388376
innerType1 = PythonQtUtils::metaTypeIdFromTypeName(names.at(0).trimmed());
389377
innerType2 = PythonQtUtils::metaTypeIdFromTypeName(names.at(1).trimmed());
390378
}
391-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
392379
if (innerType1 == QMetaType::UnknownType || innerType2 == QMetaType::UnknownType) {
393-
#else
394-
if (innerType1 == QVariant::Invalid || innerType2 == QVariant::Invalid) {
395-
#endif
396380
std::cerr << "PythonQtConvertPythonToPair: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
397381
}
398382
bool result = false;
@@ -433,11 +417,7 @@ PyObject* PythonQtConvertListOfPairToPythonList(const void* /*QList<QPair<T1,T2>
433417
{
434418
ListType* list = (ListType*)inList;
435419
static int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId)));
436-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
437420
if (innerType == QMetaType::UnknownType) {
438-
#else
439-
if (innerType == QVariant::Invalid) {
440-
#endif
441421
std::cerr << "PythonQtConvertListOfPairToPythonList: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
442422
}
443423
PyObject* result = PyTuple_New(list->size());
@@ -456,11 +436,7 @@ bool PythonQtConvertPythonListToListOfPair(PyObject* obj, void* /*QList<QPair<T1
456436
{
457437
ListType* list = (ListType*)outList;
458438
static int innerType = PythonQtMethodInfo::getInnerTemplateMetaType(QByteArray(PythonQtUtils::typeNameFromMetaTypeId(metaTypeId)));
459-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
460439
if (innerType == QMetaType::UnknownType) {
461-
#else
462-
if (innerType == QVariant::Invalid) {
463-
#endif
464440
std::cerr << "PythonQtConvertPythonListToListOfPair: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
465441
}
466442
bool result = false;
@@ -498,11 +474,7 @@ PyObject* PythonQtConvertIntegerMapToPython(const void* /*QMap<int, T>* */ inMap
498474
QList<QByteArray> names = innerTypes.split(',');
499475
innerType = PythonQtUtils::metaTypeIdFromTypeName(names.at(1).trimmed());
500476
}
501-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
502477
if (innerType == QMetaType::UnknownType) {
503-
#else
504-
if (innerType == QVariant::Invalid) {
505-
#endif
506478
std::cerr << "PythonQtConvertIntegerMapToPython: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
507479
}
508480

@@ -530,11 +502,7 @@ bool PythonQtConvertPythonToIntegerMap(PyObject* val, void* /*QMap<int, T>* */ o
530502
QList<QByteArray> names = innerTypes.split(',');
531503
innerType = PythonQtUtils::metaTypeIdFromTypeName(names.at(1).trimmed());
532504
}
533-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
534505
if (innerType == QMetaType::UnknownType) {
535-
#else
536-
if (innerType == QVariant::Invalid) {
537-
#endif
538506
std::cerr << "PythonQtConvertPythonToIntegerMap: unknown inner type " << PythonQtUtils::typeNameFromMetaTypeId(metaTypeId) << std::endl;
539507
}
540508
bool result = false;

src/PythonQtInstanceWrapper.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,11 +490,7 @@ static PyObject *PythonQtInstanceWrapper_getattro(PyObject *obj,PyObject *name)
490490
switch (member._type) {
491491
case PythonQtMemberInfo::Property:
492492
if (wrapper->_obj) {
493-
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
494493
if (member._property.userType() != QMetaType::UnknownType) {
495-
#else
496-
if (member._property.userType() != QVariant::Invalid) {
497-
#endif
498494

499495
PythonQt::ProfilingCB* profilingCB = PythonQt::priv()->profilingCB();
500496
if (profilingCB) {

0 commit comments

Comments
 (0)