From 0a07515edfbe0b8b27da102263b5d8155b84c872 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Fri, 11 Feb 2022 11:33:17 +0100 Subject: __feature__: Fix true_property overriding It was assumed that an override of a property would not make any sense, and the feature was disabled. An example showed that it _does_ make sense, and this works without any effort. This does not fix other problems which are still there, like correct handling of renamed implicit function calls. This will be addressed in another change. [ChangeLog][PySide6] true_property overriding was enabled. Change-Id: Ic22f05c6c999e7f97c47161d95e785c952168bb6 Fixes: PYSIDE-1765 Reviewed-by: Friedemann Kleint (cherry picked from commit d03776d6ef3dc0934e68b2bb7aa7260208592c3c) Reviewed-by: Qt Cherry-pick Bot --- .../tests/QtCore/snake_prop_feature_test.py | 22 +++++++++++++++++++++- sources/shiboken6/libshiboken/bindingmanager.cpp | 5 ----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/sources/pyside6/tests/QtCore/snake_prop_feature_test.py b/sources/pyside6/tests/QtCore/snake_prop_feature_test.py index 18a5e4058..61e0b5d63 100644 --- a/sources/pyside6/tests/QtCore/snake_prop_feature_test.py +++ b/sources/pyside6/tests/QtCore/snake_prop_feature_test.py @@ -46,7 +46,8 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) from init_paths import init_test_paths init_test_paths(False) -from PySide6.QtWidgets import QApplication, QWidget +from PySide6.QtCore import Property, QSize +from PySide6.QtWidgets import QApplication, QMainWindow, QWidget from PySide6.support import __feature__ """ @@ -150,6 +151,25 @@ class FeatureTest(unittest.TestCase): self.assertTrue(isinstance(UserClass.someFunc2, FunctionType)) self.assertTrue(isinstance(UserClass.add_action, MethodDescriptorType)) + def testTrueProperyCanOverride(self): + from __feature__ import true_property + + class CustomWidget(QWidget): + global prop_result + prop_result = None + + @Property(QSize) + def minimumSizeHint(self): + global prop_result + print("called") + prop_result = super().minimumSizeHint + return prop_result + + window = QMainWindow() + window.setCentralWidget(CustomWidget(window)) + window.show() + self.assertTrue(isinstance(prop_result, QSize)) + if __name__ == '__main__': unittest.main() diff --git a/sources/shiboken6/libshiboken/bindingmanager.cpp b/sources/shiboken6/libshiboken/bindingmanager.cpp index 0fc6ab78f..516ee3815 100644 --- a/sources/shiboken6/libshiboken/bindingmanager.cpp +++ b/sources/shiboken6/libshiboken/bindingmanager.cpp @@ -289,11 +289,6 @@ PyObject *BindingManager::getOverride(const void *cptr, int flag = currentSelectId(Py_TYPE(wrapper)); int propFlag = isdigit(methodName[0]) ? methodName[0] - '0' : 0; - if ((flag & 0x02) != 0 && (propFlag & 3) != 0) { - // PYSIDE-1019: Handle overriding with properties. - // They cannot be overridden (make that sure by the metaclass). - return nullptr; - } bool is_snake = flag & 0x01; PyObject *pyMethodName = nameCache[is_snake]; // borrowed if (pyMethodName == nullptr) { -- cgit v1.2.3