From d59a2c2817d8c41aba52be38d569358f45c0db74 Mon Sep 17 00:00:00 2001 From: Daniel Rogers Date: Tue, 23 Jan 2018 23:25:45 -0800 Subject: [PATCH] Fix compliation against shiboken2 head shiboken2 changed type conversion and removed a wrapper. This just deleted the class definition that is not longer valid and inlines code in a few places. fixes #3287 --- src/Gui/WidgetFactory.cpp | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/src/Gui/WidgetFactory.cpp b/src/Gui/WidgetFactory.cpp index e9182de6db..ebde79a461 100644 --- a/src/Gui/WidgetFactory.cpp +++ b/src/Gui/WidgetFactory.cpp @@ -77,7 +77,6 @@ PyTypeObject** SbkPySide_QtGuiTypes=NULL; # include # include # include -# include # include # ifdef HAVE_PYSIDE2 # define HAVE_PYSIDE @@ -114,40 +113,24 @@ PyTypeObject** SbkPySide2_QtWidgetsTypes=NULL; using namespace Gui; #if defined (HAVE_SHIBOKEN) -namespace Shiboken { -template<> struct Converter -{ - static inline bool checkType(PyObject* pyObj) { - return PyObject_TypeCheck(pyObj, &(Base::QuantityPy::Type)); - } - static inline bool isConvertible(PyObject* pyObj) { - return PyObject_TypeCheck(pyObj, &(Base::QuantityPy::Type)); - } - static inline PyObject* toPython(void* cppobj) { - return toPython(*reinterpret_cast(cppobj)); - } - static inline PyObject* toPython(Base::Quantity cpx) { - return new Base::QuantityPy(new Base::Quantity(cpx)); - } - static inline Base::Quantity toCpp(PyObject* pyobj) { - Base::Quantity q = *static_cast(pyobj)->getQuantityPtr(); - return q; - } -}; + +PyObject* toPythonFuncQuantityTyped(Base::Quantity cpx) { + return new Base::QuantityPy(new Base::Quantity(cpx)); } PyObject* toPythonFuncQuantity(const void* cpp) { - return Shiboken::Converter::toPython(const_cast(cpp)); + return toPythonFuncQuantityTyped(*reinterpret_cast(cpp)); } -void toCppPointerConvFuncQuantity(PyObject*,void*) +void toCppPointerConvFuncQuantity(PyObject* pyobj,void* cpp) { + *((Base::Quantity*)cpp) = *static_cast(pyobj)->getQuantityPtr(); } PythonToCppFunc toCppPointerCheckFuncQuantity(PyObject* obj) { - if (Shiboken::Converter::isConvertible(obj)) + if (PyObject_TypeCheck(obj, &(Base::QuantityPy::Type))) return toCppPointerConvFuncQuantity; else return 0; @@ -297,7 +280,9 @@ QObject* PythonWrapper::toQObject(const Py::Object& pyobject) Py::Object PythonWrapper::fromQIcon(const QIcon* icon) { #if defined (HAVE_SHIBOKEN) && defined(HAVE_PYSIDE) - PyObject* pyobj = Shiboken::createWrapper(icon, true); + const char* typeName = typeid(icon).name(); + PyObject* pyobj = Shiboken::Object::newObject(reinterpret_cast(Shiboken::SbkType()), + const_cast(icon), true, false, typeName); if (pyobj) return Py::asObject(pyobj); #else