aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-06-25 15:24:11 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-06-25 14:22:59 +0000
commit4d858949958e48fdffa136688f1eb82f85439404 (patch)
tree73a211458c40ac3c6c1dca629de8c7475b2191f4
parentd30a4247a5253cdbd2b7f34d4fd0ac648850fbf1 (diff)
Fix index() method of QAbstractItemModel-derived classes
Prepend virtual methods when creating function groups so that overriding method the most-derived class is seen first. Task-number: PYSIDE-570 Change-Id: I791e3da09783c4c31ac293060aed8bb2bc8472d5 Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_668.py2
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.cpp14
2 files changed, 14 insertions, 2 deletions
diff --git a/sources/pyside2/tests/QtWidgets/bug_668.py b/sources/pyside2/tests/QtWidgets/bug_668.py
index 27c73c660..05cffa39d 100644
--- a/sources/pyside2/tests/QtWidgets/bug_668.py
+++ b/sources/pyside2/tests/QtWidgets/bug_668.py
@@ -42,6 +42,8 @@ class A(QMainWindow):
v = QTreeView(self)
v.setModel(a)
self.setCentralWidget(v)
+ # Test index() method (see PYSIDE-570, PYSIDE-331)
+ index = a.index(0, 0, QModelIndex())
app = QApplication([])
m = A()
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
index 976b34141..315f10fcb 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
@@ -2490,8 +2490,18 @@ QMap< QString, AbstractMetaFunctionList > ShibokenGenerator::getFunctionGroups(c
QMap<QString, AbstractMetaFunctionList> results;
for (AbstractMetaFunction *func : qAsConst(lst)) {
- if (isGroupable(func))
- results[func->name()].append(func);
+ if (isGroupable(func)) {
+ AbstractMetaFunctionList &list = results[func->name()];
+ // If there are virtuals methods in the mix (PYSIDE-570,
+ // QFileSystemModel::index(QString,int) and
+ // QFileSystemModel::index(int,int,QModelIndex)) override, make sure
+ // the overriding method of the most-derived class is seen first
+ // and inserted into the "seenSignatures" set.
+ if (func->isVirtual())
+ list.prepend(func);
+ else
+ list.append(func);
+ }
}
return results;
}