aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6')
-rw-r--r--sources/pyside6/PySide6/QtCore/typesystem_core_common.xml6
-rw-r--r--sources/pyside6/doc/developer/add_port_example.rst10
-rw-r--r--sources/pyside6/plugins/designer/designercustomwidgets.cpp2
-rw-r--r--sources/pyside6/tests/QtCore/qobject_property_test.py48
-rw-r--r--sources/pyside6/tests/QtRemoteObjects/CMakeLists.txt3
5 files changed, 62 insertions, 7 deletions
diff --git a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml
index 0256821d4..acf9202cb 100644
--- a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml
+++ b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml
@@ -336,7 +336,8 @@
<add-conversion type="SbkObject" file="../glue/qtcore.cpp" snippet="conversion-sbkobject"/>
<add-conversion type="PyDict" check="PyDict_CheckExact(%in)" file="../glue/qtcore.cpp" snippet="conversion-pydict"/>
<add-conversion type="PyList" check="PyList_Check(%in)" file="../glue/qtcore.cpp" snippet="conversion-pylist"/>
- <add-conversion type="PyTuple" check="PyTuple_Check(%in)" file="../glue/qtcore.cpp" snippet="conversion-pylist"/>
+ <add-conversion type="PyTuple" check="PyTuple_CheckExact(%in)"
+ file="../glue/qtcore.cpp" snippet="conversion-pylist"/>
<add-conversion type="PyObject" file="../glue/qtcore.cpp" snippet="conversion-pyobject"/>
</target-to-native>
</conversion-rule>
@@ -3414,6 +3415,9 @@
<add-function signature="__repr__" return-type="str">
<inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qmetaobject-repr"/>
</add-function>
+ <modify-function signature="className()const">
+ <modify-argument index="return" pyi-type="str"/>
+ </modify-function>
<modify-function signature="indexOfClassInfo(const char *)const">
<modify-argument index="1" pyi-type="str"/>
</modify-function>
diff --git a/sources/pyside6/doc/developer/add_port_example.rst b/sources/pyside6/doc/developer/add_port_example.rst
index 909986e79..e65c3c9c8 100644
--- a/sources/pyside6/doc/developer/add_port_example.rst
+++ b/sources/pyside6/doc/developer/add_port_example.rst
@@ -67,11 +67,17 @@ Port a Qt example
- Note that our examples need to have unique names due to the doc build.
- Verify that all slots are decorated using ``@Slot``.
- Enumerations should be fully qualified (PYSIDE-1735).
+- Check the above by running the example with the environment variables:
+
+ .. code-block:: bash
+
+ export PYSIDE6_OPTION_PYTHON_ENUM=0x71
+ export QT_LOGGING_RULES=qt.pyside.libpyside.warning=true
+
- Add a ``.pyproject`` file (verify later on that docs build).
-- Add a ``doc`` directory and descriptive ``.rst`` file,
+- Add a ``doc`` directory and descriptive ``.md`` or ``.rst`` file,
and a screenshot if suitable (use ``optipng`` to reduce file size).
- Add the ``"""Port of the ... example from Qt 6"""`` doc string.
-- Try to port variable and function names to snake case convention.
- Remove C++ documentation from ``sources/pyside6/doc/additionaldocs.lst``.
.. note:: Example screenshots in ``.png`` should be optimized by
diff --git a/sources/pyside6/plugins/designer/designercustomwidgets.cpp b/sources/pyside6/plugins/designer/designercustomwidgets.cpp
index d13539859..c43af1f6d 100644
--- a/sources/pyside6/plugins/designer/designercustomwidgets.cpp
+++ b/sources/pyside6/plugins/designer/designercustomwidgets.cpp
@@ -68,7 +68,7 @@ static QString pyErrorMessage()
#else // <3.11
if (PyObject *pvalue = PyErr_GetRaisedException()) {
result = pyStr(pvalue);
- Py_DECREF(pvalue);
+ PyErr_SetRaisedException(pvalue);
}
#endif
return result;
diff --git a/sources/pyside6/tests/QtCore/qobject_property_test.py b/sources/pyside6/tests/QtCore/qobject_property_test.py
index 80387ec77..9d2bd2c56 100644
--- a/sources/pyside6/tests/QtCore/qobject_property_test.py
+++ b/sources/pyside6/tests/QtCore/qobject_property_test.py
@@ -9,6 +9,7 @@ import sys
import unittest
from pathlib import Path
+from typing import NamedTuple
sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
@@ -16,6 +17,9 @@ init_test_paths(False)
from PySide6.QtCore import QObject, Property, Signal
+Point = NamedTuple("Point", [("x", float), ("y", float)])
+
+
class MyObjectWithNotifyProperty(QObject):
def __init__(self, parent=None):
QObject.__init__(self, parent)
@@ -52,6 +56,23 @@ class MyObjectWithOtherClassProperty(QObject):
otherclass = Property(OtherClass, fget=_get_otherclass, fset=_set_otherclass)
+class TestVariantPropertyObject(QObject):
+ """Helper for testing QVariant conversion in properties and signals
+ (PYSIDE-3206, PYSIDE-3244). It uses a property of list type that
+ can passed a QVariant list with various element types."""
+ def __init__(self, parent=None):
+ super().__init__(parent)
+ self._property = None
+
+ def set_property(self, v):
+ self._property = v
+
+ def get_property(self):
+ return self._property
+
+ testProperty = Property(list, fget=get_property, fset=set_property)
+
+
class PropertyWithNotify(unittest.TestCase):
def called(self):
self.called_ = True
@@ -84,5 +105,32 @@ class QObjectWithOtherClassPropertyTest(unittest.TestCase):
self.assertTrue(type(pv) is OtherClass)
+class VariantPropertyTest(unittest.TestCase):
+ """Test QVariant conversion in properties and signals (PYSIDE-3206, PYSIDE-3244).
+ It uses a property of list type that is passed a QVariantList
+ with various element types when using QObject.setProperty()."""
+
+ def testIt(self):
+ to = TestVariantPropertyObject()
+ idx = to.metaObject().indexOfProperty("testProperty")
+ self.assertTrue(idx != -1)
+
+ # List
+ to.setProperty("testProperty", [[1, 2]])
+ self.assertEqual(type(to.get_property()[0]), list)
+
+ # Dict
+ to.setProperty("testProperty", [{"key": 42}])
+ self.assertEqual(type(to.get_property()[0]), dict)
+
+ # PYSIDE-3206 (DBus): Convert a tuple to a list
+ to.setProperty("testProperty", [(1, 2)])
+ self.assertEqual(type(to.get_property()[0]), list)
+
+ # PYSIDE-324: The tuple conversion must not occur for named tuples
+ to.setProperty("testProperty", [Point(1, 2)])
+ self.assertEqual(type(to.get_property()[0]), Point)
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside6/tests/QtRemoteObjects/CMakeLists.txt b/sources/pyside6/tests/QtRemoteObjects/CMakeLists.txt
index ace1a00fa..72e7d3cea 100644
--- a/sources/pyside6/tests/QtRemoteObjects/CMakeLists.txt
+++ b/sources/pyside6/tests/QtRemoteObjects/CMakeLists.txt
@@ -1,11 +1,8 @@
# Copyright (C) 2025 Ford Motor Company
# SPDX-License-Identifier: BSD-3-Clause
-# FIXME: TypeError: Failed to generate default value. Error: name 'int' is not defined. Problematic code: int(2)
-if(NOT APPLE)
PYSIDE_TEST(repfile_test.py)
PYSIDE_TEST(dynamic_types_test.py)
PYSIDE_TEST(integration_test.py)
add_subdirectory(cpp_interop)
-endif()