From 93bb5d777e6db0ba8d2b216832bf4211476c581e Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Fri, 9 Dec 2011 11:21:38 -0200 Subject: Fix bug 1083 - "winId returns a PyCObject making it impossible to compare two winIds" --- PySide/QtGui/glue/wid_conversions.h | 25 +++---------------------- PySide/QtGui/typesystem_gui_common.xml | 2 +- 2 files changed, 4 insertions(+), 23 deletions(-) (limited to 'PySide') diff --git a/PySide/QtGui/glue/wid_conversions.h b/PySide/QtGui/glue/wid_conversions.h index 183e682fe..68d752884 100644 --- a/PySide/QtGui/glue/wid_conversions.h +++ b/PySide/QtGui/glue/wid_conversions.h @@ -11,14 +11,7 @@ struct Converter static bool isConvertible(PyObject* pyobj) { - if (pyobj == Py_None) - return true; - -#ifdef IS_PY3K - return PyCapsule_CheckExact(pyobj); -#else - return PyCObject_Check(pyobj); -#endif + return pyobj == Py_None || PyNumber_Check(pyobj); } static inline PyObject* toPython(void* cppobj) @@ -30,26 +23,14 @@ struct Converter static PyObject* toPython(WId cppobj) { - if (!cppobj) - Py_RETURN_NONE; - -#ifdef IS_PY3K - return PyCapsule_New(cppobj, 0, 0); -#else - return PyCObject_FromVoidPtr(cppobj, 0); -#endif + return PyLong_FromVoidPtr((void*)cppobj); } static WId toCpp(PyObject* pyobj) { if (pyobj == Py_None) return 0; - -#ifdef IS_PY3K - return (WId)PyCapsule_GetPointer(pyobj, 0); -#else - return (WId)PyCObject_AsVoidPtr(pyobj); -#endif + return (WId)PyLong_AsVoidPtr(pyobj); } }; diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 755f4a971..e4a6f440f 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -4245,7 +4245,7 @@ If a widget is non-native (alien) and winId() is invoked on it, that widget will be provided a native handle. - On X11 the type returned is long, on other platforms it's a PyCObject. + On X11 the type returned is long, on other platforms it's void pointer casted to a Python long long. This value may change at run-time. An event with type PySide.QtCore.QEvent.WinIdChange will be sent to the widget following a change in window system identifier. -- cgit v1.2.3