aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2021-07-08 16:14:11 +0200
committerChristian Tismer <tismer@stackless.com>2021-07-22 09:51:23 +0200
commit7f8ffe2620a6d31fb0b5aa3b78d9a7eca8eaff65 (patch)
tree3b11d08f7f593d8931b8bad2b04b65ead26d0e6e
parentea9b082947933a7d381e177292a36dc6c5b0574c (diff)
PySide: fix QItemSelection default and QItemSelection.__add__
QItemSelection with no argument should create an empty selector. This worked in Qt5. In Qt6, everything works but the empty argument. Without further analysis, this might be related to the new [default] tag found in the Qt6 QItemSelection documentation? Fixing this bug leads directly to the add operator, which returns a list instead of a combined QItemSelection. Fixed by removing `operator+(list<QItemSelectionRange>)` and re-adding it with QItemSelection Unrelated, occurred during bug hunting. Task-number: PYSIDE-535 Change-Id: Ie5b881659e54fc0eebc8c9903df6e14eb2788565 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 16429c860888578b5bda7fd75437dd1f6a79b331)
-rw-r--r--build_history/blacklist.txt3
-rw-r--r--sources/pyside6/PySide6/QtCore/typesystem_core_common.xml9
-rw-r--r--sources/pyside6/PySide6/glue/qtcore.cpp5
3 files changed, 14 insertions, 3 deletions
diff --git a/build_history/blacklist.txt b/build_history/blacklist.txt
index f7fb0c387..7786fe989 100644
--- a/build_history/blacklist.txt
+++ b/build_history/blacklist.txt
@@ -37,9 +37,6 @@
# Open GL functions failures on macOS (2/2020)
[registry::existence_test]
darwin
-# QItemSelection::operator+() degenerates to list<QItemSelectionRange> for which added operator==() does not work
-[QtWidgets::bug_785]
- qt6
[QtCore::bug_686]
linux ci
[QtCore::qthread_signal_test]
diff --git a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml
index 16d739056..e4a48bb25 100644
--- a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml
+++ b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml
@@ -1541,6 +1541,15 @@
not see due to the TMP expression of the return type. -->
<add-function signature="operator==(const QItemSelection&amp;)" return-type="bool"/>
<add-function signature="operator!=(const QItemSelection&amp;)" return-type="bool"/>
+ <!-- For some reason, the empty selection is not seen. Maybe related to the new [default]
+ tag in Qt6? -->
+ <declare-function signature="QItemSelection()" return-type="QItemSelection" />
+ <!-- The __add__ function creates a result list, instead of using the inherited type.
+ Solved for now by removing and re-adding with the correct type. -->
+ <modify-function signature="operator+(QList&lt;QItemSelectionRange&gt;)const" remove="all" />
+ <add-function signature="operator+(QItemSelection)" return-type="QItemSelection">
+ <inject-code class="target" position="beginning" file="../glue/qtcore.cpp" snippet="qitemselection-add"/>
+ </add-function>
</value-type>
<object-type name="QItemSelectionModel">
diff --git a/sources/pyside6/PySide6/glue/qtcore.cpp b/sources/pyside6/PySide6/glue/qtcore.cpp
index 9bc516f08..8228e3c19 100644
--- a/sources/pyside6/PySide6/glue/qtcore.cpp
+++ b/sources/pyside6/PySide6/glue/qtcore.cpp
@@ -1704,6 +1704,11 @@ PyMem_Free(temp);
%out = %OUTTYPE();
// @snippet conversion-pynone
+// @snippet qitemselection-add
+auto res = (*%CPPSELF) + cppArg0;
+%PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](res);
+// @snippet qitemselection-add
+
// @snippet conversion-pystring-char
char c = %CONVERTTOCPP[char](%in);
%out = %OUTTYPE(c);