From d422019cd729d767bbb36d35aa4e9eee22489561 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 2 Aug 2019 16:31:13 +0200 Subject: [PATCH] use shiboken version number to check for existence of Shiboken::ObjectType::typeForTypeName --- src/Gui/WidgetFactory.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Gui/WidgetFactory.cpp b/src/Gui/WidgetFactory.cpp index af396c499a..405604b953 100644 --- a/src/Gui/WidgetFactory.cpp +++ b/src/Gui/WidgetFactory.cpp @@ -82,20 +82,27 @@ PyTypeObject** SbkPySide_QtGuiTypes=nullptr; # include # ifdef HAVE_PYSIDE2 # define HAVE_PYSIDE -// Since Qt >= 5.12 shiboken offers a method to get wrapper by class name (typeForTypeName) + +// Since version 5.12 shiboken offers a method to get wrapper by class name (typeForTypeName) // This helps to avoid to include the PySide2 headers since MSVC has a compiler bug when // compiling together with std::bitset (https://bugreports.qt.io/browse/QTBUG-72073) -# if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0)) + +# define SHIBOKEN_FULL_VERSION QT_VERSION_CHECK(SHIBOKEN_MAJOR_VERSION, SHIBOKEN_MINOR_VERSION, SHIBOKEN_MICRO_VERSION) +# if (SHIBOKEN_FULL_VERSION >= QT_VERSION_CHECK(5, 12, 0)) +# define HAVE_SHIBOKEN_TYPE_FOR_TYPENAME +# endif + +# ifndef HAVE_SHIBOKEN_TYPE_FOR_TYPENAME # include # include # include -#endif +# endif # include PyTypeObject** SbkPySide2_QtCoreTypes=nullptr; PyTypeObject** SbkPySide2_QtGuiTypes=nullptr; PyTypeObject** SbkPySide2_QtWidgetsTypes=nullptr; -# endif -#endif +# endif // HAVE_PYSIDE2 +#endif // HAVE_SHIBOKEN2 #if defined(__clang__) # pragma clang diagnostic pop @@ -285,12 +292,12 @@ template PyTypeObject *getPyTypeObjectForTypeName() { #if defined (HAVE_SHIBOKEN) && defined(HAVE_PYSIDE) -#if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0)) - return Shiboken::SbkType(); -#else +#if defined (HAVE_SHIBOKEN_TYPE_FOR_TYPENAME) SbkObjectType* sbkType = Shiboken::ObjectType::typeForTypeName(typeid(qttype).name()); if (sbkType) return &(sbkType->type); +#else + return Shiboken::SbkType(); #endif #endif return nullptr;