pyside2-5.15.2.1.patch 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. diff --git a/build_scripts/utils.py b/build_scripts/utils.py
  2. index 0782ae036..53231ce14 100644
  3. --- a/build_scripts/utils.py
  4. +++ b/build_scripts/utils.py
  5. @@ -833,7 +833,7 @@ def ldd(executable_path):
  6. chosen_rtld = None
  7. # List of ld's considered by ldd on Ubuntu (here's hoping it's the
  8. # same on all distros).
  9. - rtld_list = ["/lib/ld-linux.so.2", "/lib64/ld-linux-x86-64.so.2", "/libx32/ld-linux-x32.so.2"]
  10. + rtld_list = ["/lib/ld-linux.so.2", "/lib64/ld-linux-x86-64.so.2", "/libx32/ld-linux-x32.so.2", "/lib/ld-linux-aarch64.so.1"]
  11. # Choose appropriate runtime dynamic linker.
  12. for rtld in rtld_list:
  13. diff --git a/sources/pyside2-tools b/sources/pyside2-tools
  14. --- a/sources/pyside2-tools
  15. +++ b/sources/pyside2-tools
  16. @@ -1 +1 @@
  17. -Subproject commit a8448837204faee0b457d1e2d4cbf574a2811114
  18. +Subproject commit a8448837204faee0b457d1e2d4cbf574a2811114-dirty
  19. diff --git a/sources/pyside2/libpyside/CMakeLists.txt b/sources/pyside2/libpyside/CMakeLists.txt
  20. index e31c87eef..a8fdf731a 100644
  21. --- a/sources/pyside2/libpyside/CMakeLists.txt
  22. +++ b/sources/pyside2/libpyside/CMakeLists.txt
  23. @@ -1,13 +1,5 @@
  24. project(libpyside)
  25. -if(${Qt${QT_MAJOR_VERSION}Qml_FOUND})
  26. - if(NOT "${Qt${QT_MAJOR_VERSION}Qml_PRIVATE_INCLUDE_DIRS}" MATCHES "/QtQml/")
  27. - string(REPLACE "/QtCore" "/QtQml" replaceme "${Qt${QT_MAJOR_VERSION}Core_PRIVATE_INCLUDE_DIRS}")
  28. - list(APPEND Qt${QT_MAJOR_VERSION}Qml_PRIVATE_INCLUDE_DIRS ${replaceme})
  29. - list(REMOVE_DUPLICATES Qt${QT_MAJOR_VERSION}Qml_PRIVATE_INCLUDE_DIRS)
  30. - endif()
  31. -endif()
  32. -
  33. if(${Qt${QT_MAJOR_VERSION}Quick_FOUND})
  34. if(NOT "${Qt${QT_MAJOR_VERSION}Quick_PRIVATE_INCLUDE_DIRS}" MATCHES "/QtQuick/")
  35. string(REPLACE "/QtCore" "/QtQuick" replaceme "${Qt${QT_MAJOR_VERSION}Core_PRIVATE_INCLUDE_DIRS}")
  36. @@ -18,25 +10,9 @@ if(${Qt${QT_MAJOR_VERSION}Quick_FOUND})
  37. endif()
  38. set(QML_PRIVATE_API_SUPPORT 0)
  39. -if(Qt${QT_MAJOR_VERSION}Qml_FOUND)
  40. - # Used for registering custom QQuickItem classes defined in Python code.
  41. - set(QML_SUPPORT 1)
  42. - set(QML_INCLUDES ${Qt${QT_MAJOR_VERSION}Qml_INCLUDE_DIRS})
  43. - set(QML_LIBRARIES ${Qt${QT_MAJOR_VERSION}Qml_LIBRARIES})
  44. -
  45. - if(Qt${QT_MAJOR_VERSION}Qml_PRIVATE_INCLUDE_DIRS)
  46. - # Used for transforming QML exceptions into Python exceptions.
  47. - set(QML_PRIVATE_API_SUPPORT 1)
  48. - set(QML_INCLUDES ${QML_INCLUDES} ${Qt${QT_MAJOR_VERSION}Qml_PRIVATE_INCLUDE_DIRS})
  49. - else()
  50. - message(WARNING "QML private API include files could not be found, support for catching QML exceptions inside Python code will not work.")
  51. - endif()
  52. -else()
  53. - set(QML_SUPPORT 0)
  54. - set(QML_PRIVATE_API_SUPPORT 0)
  55. - set(QML_INCLUDES "")
  56. - set(QML_LIBRARIES "")
  57. -endif()
  58. +set(QML_SUPPORT 0)
  59. +set(QML_INCLUDES "")
  60. +set(QML_LIBRARIES "")
  61. set(libpyside_SRC
  62. dynamicqmetaobject.cpp
  63. diff --git a/sources/pyside2/libpyside/pyside.cpp b/sources/pyside2/libpyside/pyside.cpp
  64. index 219b99d48..f33e4f724 100644
  65. --- a/sources/pyside2/libpyside/pyside.cpp
  66. +++ b/sources/pyside2/libpyside/pyside.cpp
  67. @@ -414,7 +414,7 @@ static const char invalidatePropertyName[] = "_PySideInvalidatePtr";
  68. // class by walking up the meta objects.
  69. static const char *typeName(QObject *cppSelf)
  70. {
  71. - const char *typeName = typeid(*cppSelf).name();
  72. + const char *typeName = getTypeId(*cppSelf).name();
  73. if (!Shiboken::Conversions::getConverter(typeName)) {
  74. for (auto metaObject = cppSelf->metaObject(); metaObject; metaObject = metaObject->superClass()) {
  75. const char *name = metaObject->className();
  76. diff --git a/sources/pyside2/libpyside/pyside.h b/sources/pyside2/libpyside/pyside.h
  77. index c1a298cc8..91e648f47 100644
  78. --- a/sources/pyside2/libpyside/pyside.h
  79. +++ b/sources/pyside2/libpyside/pyside.h
  80. @@ -50,12 +50,57 @@
  81. #include <QtCore/QMetaType>
  82. #include <QtCore/QHash>
  83. +#include <QtCore/QMetaObject>
  84. +#include <QtCore/QObject>
  85. +
  86. +#include <type_traits>
  87. +#include <typeinfo>
  88. struct SbkObjectType;
  89. namespace PySide
  90. {
  91. +// Analog for std::type_info with the name field, to allow getTypeId to be used in lieu of typeid
  92. +class TypeInfo
  93. +{
  94. +private:
  95. + const char* m_name = nullptr;
  96. +
  97. +public:
  98. + explicit TypeInfo(const char* name) : m_name(name) {}
  99. + const char* name() const { return m_name; }
  100. +};
  101. +
  102. +// getTypeId returns an interface similar to the std::type_info returned by typeid, but will attempt to use
  103. +// Qt's meta-object system for QObject subclasses instead - this allows Shiboken to interop with libraries that
  104. +// are built without RTTI
  105. +template <class T>
  106. +const TypeInfo getTypeId(typename std::enable_if<std::is_base_of<QObject, T>::value>::type* = 0)
  107. +{
  108. + const char* typeName = T::staticMetaObject.className();
  109. + return TypeInfo(typeName);
  110. +}
  111. +
  112. +template <class T>
  113. +const TypeInfo getTypeId(typename std::enable_if<!std::is_base_of<QObject, T>::value>::type* = 0)
  114. +{
  115. + return TypeInfo(typeid(T).name());
  116. +}
  117. +
  118. +template <class T>
  119. +const TypeInfo getTypeId(const T& t, typename std::enable_if<std::is_base_of<QObject, T>::value>::type* = 0)
  120. +{
  121. + const char* typeName = t.metaObject() ? t.metaObject()->className() : T::staticMetaObject.className();
  122. + return TypeInfo(typeName);
  123. +}
  124. +
  125. +template <class T>
  126. +const TypeInfo getTypeId(const T& t, typename std::enable_if<!std::is_base_of<QObject, T>::value>::type* = 0)
  127. +{
  128. + return TypeInfo(typeid(t).name());
  129. +}
  130. +
  131. PYSIDE_API void init(PyObject *module);
  132. /**
  133. diff --git a/sources/shiboken2/CMakeLists.txt b/sources/shiboken2/CMakeLists.txt
  134. index 3de5d3223..8cc960e99 100644
  135. --- a/sources/shiboken2/CMakeLists.txt
  136. +++ b/sources/shiboken2/CMakeLists.txt
  137. @@ -78,7 +78,7 @@ if (NOT PYTHON_EXTENSION_SUFFIX)
  138. get_python_extension_suffix()
  139. endif()
  140. -option(FORCE_LIMITED_API "Enable the limited API." "yes")
  141. +option(FORCE_LIMITED_API "Enable the limited API." ON)
  142. set(PYTHON_LIMITED_API 0)
  143. shiboken_check_if_limited_api()
  144. diff --git a/sources/shiboken2/data/shiboken_helpers.cmake b/sources/shiboken2/data/shiboken_helpers.cmake
  145. index 5e0c6ea72..1097991c3 100644
  146. --- a/sources/shiboken2/data/shiboken_helpers.cmake
  147. +++ b/sources/shiboken2/data/shiboken_helpers.cmake
  148. @@ -298,7 +298,7 @@ macro(shiboken_check_if_limited_api)
  149. OUTPUT_VARIABLE PYTHON_LIMITED_LIBRARIES
  150. OUTPUT_STRIP_TRAILING_WHITESPACE)
  151. - if(FORCE_LIMITED_API STREQUAL "yes")
  152. + if(FORCE_LIMITED_API)
  153. if (${PYTHON_VERSION_MAJOR} EQUAL 3 AND ${PYTHON_VERSION_MINOR} GREATER 4)
  154. # GREATER_EQUAL is available only from cmake 3.7 on. We mean python 3.5 .
  155. set(PYTHON_LIMITED_API 1)
  156. diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
  157. index 38b596a5f..1aed4286b 100644
  158. --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
  159. +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
  160. @@ -59,7 +59,11 @@ static const char typeNameFunc[] = R"CPP(
  161. template <class T>
  162. static const char *typeNameOf(const T &t)
  163. {
  164. +#ifdef PYSIDE_H
  165. + const char *typeName = PySide::getTypeId<T>(t).name();
  166. +#else
  167. const char *typeName = typeid(t).name();
  168. +#endif //PYSIDE_H
  169. auto size = std::strlen(typeName);
  170. #if defined(Q_CC_MSVC) // MSVC: "class QPaintDevice * __ptr64"
  171. if (auto lastStar = strchr(typeName, '*')) {
  172. diff --git a/sources/shiboken2/libshiboken/pep384impl.cpp b/sources/shiboken2/libshiboken/pep384impl.cpp
  173. index 66df0fd94..b84c93426 100644
  174. --- a/sources/shiboken2/libshiboken/pep384impl.cpp
  175. +++ b/sources/shiboken2/libshiboken/pep384impl.cpp
  176. @@ -751,9 +751,7 @@ _Pep_PrivateMangle(PyObject *self, PyObject *name)
  177. #endif // IS_PY2
  178. Shiboken::AutoDecRef privateobj(PyObject_GetAttr(
  179. reinterpret_cast<PyObject *>(Py_TYPE(self)), Shiboken::PyMagicName::name()));
  180. -#ifndef Py_LIMITED_API
  181. - return _Py_Mangle(privateobj, name);
  182. -#else
  183. +
  184. // PYSIDE-1436: _Py_Mangle is no longer exposed; implement it always.
  185. // The rest of this function is our own implementation of _Py_Mangle.
  186. // Please compare the original function in compile.c .
  187. @@ -789,7 +787,7 @@ _Pep_PrivateMangle(PyObject *self, PyObject *name)
  188. if (amount > big_stack)
  189. free(resbuf);
  190. return result;
  191. -#endif // else Py_LIMITED_API
  192. +
  193. }
  194. /*****************************************************************************
  195. diff --git a/sources/shiboken2/libshiboken/signature/signature_helper.cpp b/sources/shiboken2/libshiboken/signature/signature_helper.cpp
  196. index 2b360c786..0246ec61d 100644
  197. --- a/sources/shiboken2/libshiboken/signature/signature_helper.cpp
  198. +++ b/sources/shiboken2/libshiboken/signature/signature_helper.cpp
  199. @@ -236,7 +236,7 @@ static PyObject *_build_new_entry(PyObject *new_name, PyObject *value)
  200. PyObject *new_value = PyDict_Copy(value);
  201. PyObject *multi = PyDict_GetItem(value, PyName::multi());
  202. if (multi != nullptr && Py_TYPE(multi) == &PyList_Type) {
  203. - ssize_t len = PyList_Size(multi);
  204. + Py_ssize_t len = PyList_Size(multi);
  205. AutoDecRef list(PyList_New(len));
  206. if (list.isNull())
  207. return nullptr;
  208. @@ -314,7 +314,7 @@ PyObject *_address_to_stringlist(PyObject *numkey)
  209. * When needed in `PySide_BuildSignatureProps`, the strings are
  210. * finally materialized.
  211. */
  212. - ssize_t address = PyNumber_AsSsize_t(numkey, PyExc_ValueError);
  213. + Py_ssize_t address = PyNumber_AsSsize_t(numkey, PyExc_ValueError);
  214. if (address == -1 && PyErr_Occurred())
  215. return nullptr;
  216. char **sig_strings = reinterpret_cast<char **>(address);