summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-01-03 16:00:46 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-01-04 09:39:39 +0000
commitb628c1643cadb2a4a6fb88d336ebd4aace3bb06a (patch)
tree574839ada486ac5f8298750c983a46afe6361eec
parente254c3c2aa140016e298107a0297885234abfde7 (diff)
Fix crash when mixing static overloads with instance methods in derived classes
Use METH_STATIC only when there are no instance methods in the same class. Unearthed by a clash of QPlainTextEdit::find() and static QWidget::find(WId). Change-Id: I891c678e004a0abc3937437b0cac26e8094853de Fixes: PYSIDE-886 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--sources/pyside2/tests/pysidetest/new_inherited_functions_test.py6
-rw-r--r--sources/pyside2/tests/registry/exists_darwin_5_12_0_ci.py4
-rw-r--r--sources/pyside2/tests/registry/exists_opensuse423_5_12_0_ci.py4
-rw-r--r--sources/pyside2/tests/registry/exists_redhatenterpriselinuxworkstation74_5_12_0_ci.py4
-rw-r--r--sources/pyside2/tests/registry/exists_win32_5_12_0_ci.py4
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp14
6 files changed, 26 insertions, 10 deletions
diff --git a/sources/pyside2/tests/pysidetest/new_inherited_functions_test.py b/sources/pyside2/tests/pysidetest/new_inherited_functions_test.py
index 54b81aca..09e5f261 100644
--- a/sources/pyside2/tests/pysidetest/new_inherited_functions_test.py
+++ b/sources/pyside2/tests/pysidetest/new_inherited_functions_test.py
@@ -85,15 +85,16 @@ new_functions += """
PySide2.QtWidgets.QListWidget().closePersistentEditor(qModelIndex)
PySide2.QtWidgets.QListWidget().openPersistentEditor(qModelIndex)
PySide2.QtWidgets.QMessageBox().open()
- PySide2.QtWidgets.QPlainTextEdit.find(quintptr)
+ PySide2.QtWidgets.QPlainTextEdit().find(findStr)
PySide2.QtWidgets.QProgressDialog().open()
PySide2.QtWidgets.QStackedLayout().widget()
# PySide2.QtWidgets.QStylePainter().begin(qPaintDevice) # QPaintDevice: NotImplementedError
PySide2.QtWidgets.QTableWidget().closePersistentEditor(qModelIndex)
PySide2.QtWidgets.QTableWidget().openPersistentEditor(qModelIndex)
- PySide2.QtWidgets.QTextEdit.find(quintptr)
+ PySide2.QtWidgets.QTextEdit().find(findStr)
PySide2.QtWidgets.QTreeWidget().closePersistentEditor(qModelIndex)
PySide2.QtWidgets.QTreeWidget().openPersistentEditor(qModelIndex)
+ PySide2.QtWidgets.QWidget.find(quintptr)
""" if "PySide2.QtWidgets" in sys.modules else ""
new_functions += """
@@ -130,6 +131,7 @@ class MainTest(unittest.TestCase):
int = 42
qint64 = 42
tfarg = os.path.join(PySide2.QtCore.QDir.tempPath(), "XXXXXX.tmp")
+ findStr = 'bla'
orientation = PySide2.QtCore.Qt.Orientation()
openMode = PySide2.QtCore.QIODevice.OpenMode(PySide2.QtCore.QIODevice.ReadOnly)
qModelIndex = PySide2.QtCore.QModelIndex()
diff --git a/sources/pyside2/tests/registry/exists_darwin_5_12_0_ci.py b/sources/pyside2/tests/registry/exists_darwin_5_12_0_ci.py
index fec59177..a2b6aa14 100644
--- a/sources/pyside2/tests/registry/exists_darwin_5_12_0_ci.py
+++ b/sources/pyside2/tests/registry/exists_darwin_5_12_0_ci.py
@@ -11099,7 +11099,7 @@ if "PySide2.QtWidgets" in sys.modules:
"QPlainTextEdit.ensureCursorVisible": (),
"QPlainTextEdit.event": ('PySide2.QtCore.QEvent',),
"QPlainTextEdit.extraSelections": (),
- "QPlainTextEdit.find": [('PySide2.QtCore.QRegExp', 'PySide2.QtGui.QTextDocument.FindFlags'), ('int',), ('str', 'PySide2.QtGui.QTextDocument.FindFlags')],
+ "QPlainTextEdit.find": [('PySide2.QtCore.QRegExp', 'PySide2.QtGui.QTextDocument.FindFlags'), ('str', 'PySide2.QtGui.QTextDocument.FindFlags')],
"QPlainTextEdit.firstVisibleBlock": (),
"QPlainTextEdit.focusInEvent": ('PySide2.QtGui.QFocusEvent',),
"QPlainTextEdit.focusNextPrevChild": ('bool',),
@@ -12163,7 +12163,7 @@ if "PySide2.QtWidgets" in sys.modules:
"QTextEdit.ensureCursorVisible": (),
"QTextEdit.event": ('PySide2.QtCore.QEvent',),
"QTextEdit.extraSelections": (),
- "QTextEdit.find": [('PySide2.QtCore.QRegExp', 'PySide2.QtGui.QTextDocument.FindFlags'), ('int',), ('str', 'PySide2.QtGui.QTextDocument.FindFlags')],
+ "QTextEdit.find": [('PySide2.QtCore.QRegExp', 'PySide2.QtGui.QTextDocument.FindFlags'), ('str', 'PySide2.QtGui.QTextDocument.FindFlags')],
"QTextEdit.focusInEvent": ('PySide2.QtGui.QFocusEvent',),
"QTextEdit.focusNextPrevChild": ('bool',),
"QTextEdit.focusOutEvent": ('PySide2.QtGui.QFocusEvent',),
diff --git a/sources/pyside2/tests/registry/exists_opensuse423_5_12_0_ci.py b/sources/pyside2/tests/registry/exists_opensuse423_5_12_0_ci.py
index 191a8720..5cb8a230 100644
--- a/sources/pyside2/tests/registry/exists_opensuse423_5_12_0_ci.py
+++ b/sources/pyside2/tests/registry/exists_opensuse423_5_12_0_ci.py
@@ -11097,7 +11097,7 @@ if "PySide2.QtWidgets" in sys.modules:
"QPlainTextEdit.ensureCursorVisible": (),
"QPlainTextEdit.event": ('PySide2.QtCore.QEvent',),
"QPlainTextEdit.extraSelections": (),
- "QPlainTextEdit.find": [('PySide2.QtCore.QRegExp', 'PySide2.QtGui.QTextDocument.FindFlags'), ('int',), ('str', 'PySide2.QtGui.QTextDocument.FindFlags')],
+ "QPlainTextEdit.find": [('PySide2.QtCore.QRegExp', 'PySide2.QtGui.QTextDocument.FindFlags'), ('str', 'PySide2.QtGui.QTextDocument.FindFlags')],
"QPlainTextEdit.firstVisibleBlock": (),
"QPlainTextEdit.focusInEvent": ('PySide2.QtGui.QFocusEvent',),
"QPlainTextEdit.focusNextPrevChild": ('bool',),
@@ -12161,7 +12161,7 @@ if "PySide2.QtWidgets" in sys.modules:
"QTextEdit.ensureCursorVisible": (),
"QTextEdit.event": ('PySide2.QtCore.QEvent',),
"QTextEdit.extraSelections": (),
- "QTextEdit.find": [('PySide2.QtCore.QRegExp', 'PySide2.QtGui.QTextDocument.FindFlags'), ('int',), ('str', 'PySide2.QtGui.QTextDocument.FindFlags')],
+ "QTextEdit.find": [('PySide2.QtCore.QRegExp', 'PySide2.QtGui.QTextDocument.FindFlags'), ('str', 'PySide2.QtGui.QTextDocument.FindFlags')],
"QTextEdit.focusInEvent": ('PySide2.QtGui.QFocusEvent',),
"QTextEdit.focusNextPrevChild": ('bool',),
"QTextEdit.focusOutEvent": ('PySide2.QtGui.QFocusEvent',),
diff --git a/sources/pyside2/tests/registry/exists_redhatenterpriselinuxworkstation74_5_12_0_ci.py b/sources/pyside2/tests/registry/exists_redhatenterpriselinuxworkstation74_5_12_0_ci.py
index 402aa4c7..969ac36c 100644
--- a/sources/pyside2/tests/registry/exists_redhatenterpriselinuxworkstation74_5_12_0_ci.py
+++ b/sources/pyside2/tests/registry/exists_redhatenterpriselinuxworkstation74_5_12_0_ci.py
@@ -11097,7 +11097,7 @@ if "PySide2.QtWidgets" in sys.modules:
"QPlainTextEdit.ensureCursorVisible": (),
"QPlainTextEdit.event": ('PySide2.QtCore.QEvent',),
"QPlainTextEdit.extraSelections": (),
- "QPlainTextEdit.find": [('PySide2.QtCore.QRegExp', 'PySide2.QtGui.QTextDocument.FindFlags'), ('int',), ('str', 'PySide2.QtGui.QTextDocument.FindFlags')],
+ "QPlainTextEdit.find": [('PySide2.QtCore.QRegExp', 'PySide2.QtGui.QTextDocument.FindFlags'), ('str', 'PySide2.QtGui.QTextDocument.FindFlags')],
"QPlainTextEdit.firstVisibleBlock": (),
"QPlainTextEdit.focusInEvent": ('PySide2.QtGui.QFocusEvent',),
"QPlainTextEdit.focusNextPrevChild": ('bool',),
@@ -12161,7 +12161,7 @@ if "PySide2.QtWidgets" in sys.modules:
"QTextEdit.ensureCursorVisible": (),
"QTextEdit.event": ('PySide2.QtCore.QEvent',),
"QTextEdit.extraSelections": (),
- "QTextEdit.find": [('PySide2.QtCore.QRegExp', 'PySide2.QtGui.QTextDocument.FindFlags'), ('int',), ('str', 'PySide2.QtGui.QTextDocument.FindFlags')],
+ "QTextEdit.find": [('PySide2.QtCore.QRegExp', 'PySide2.QtGui.QTextDocument.FindFlags'), ('str', 'PySide2.QtGui.QTextDocument.FindFlags')],
"QTextEdit.focusInEvent": ('PySide2.QtGui.QFocusEvent',),
"QTextEdit.focusNextPrevChild": ('bool',),
"QTextEdit.focusOutEvent": ('PySide2.QtGui.QFocusEvent',),
diff --git a/sources/pyside2/tests/registry/exists_win32_5_12_0_ci.py b/sources/pyside2/tests/registry/exists_win32_5_12_0_ci.py
index 406f9b2e..189e5c74 100644
--- a/sources/pyside2/tests/registry/exists_win32_5_12_0_ci.py
+++ b/sources/pyside2/tests/registry/exists_win32_5_12_0_ci.py
@@ -11110,7 +11110,7 @@ if "PySide2.QtWidgets" in sys.modules:
"QPlainTextEdit.ensureCursorVisible": (),
"QPlainTextEdit.event": ('PySide2.QtCore.QEvent',),
"QPlainTextEdit.extraSelections": (),
- "QPlainTextEdit.find": [('PySide2.QtCore.QRegExp', 'PySide2.QtGui.QTextDocument.FindFlags'), ('int',), ('str', 'PySide2.QtGui.QTextDocument.FindFlags')],
+ "QPlainTextEdit.find": [('PySide2.QtCore.QRegExp', 'PySide2.QtGui.QTextDocument.FindFlags'), ('str', 'PySide2.QtGui.QTextDocument.FindFlags')],
"QPlainTextEdit.firstVisibleBlock": (),
"QPlainTextEdit.focusInEvent": ('PySide2.QtGui.QFocusEvent',),
"QPlainTextEdit.focusNextPrevChild": ('bool',),
@@ -12174,7 +12174,7 @@ if "PySide2.QtWidgets" in sys.modules:
"QTextEdit.ensureCursorVisible": (),
"QTextEdit.event": ('PySide2.QtCore.QEvent',),
"QTextEdit.extraSelections": (),
- "QTextEdit.find": [('PySide2.QtCore.QRegExp', 'PySide2.QtGui.QTextDocument.FindFlags'), ('int',), ('str', 'PySide2.QtGui.QTextDocument.FindFlags')],
+ "QTextEdit.find": [('PySide2.QtCore.QRegExp', 'PySide2.QtGui.QTextDocument.FindFlags'), ('str', 'PySide2.QtGui.QTextDocument.FindFlags')],
"QTextEdit.focusInEvent": ('PySide2.QtGui.QFocusEvent',),
"QTextEdit.focusNextPrevChild": ('bool',),
"QTextEdit.focusOutEvent": ('PySide2.QtGui.QFocusEvent',),
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index 9df0d61c..76f902c0 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -448,6 +448,7 @@ void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext)
for (FunctionGroupMapIt it = functionGroups.cbegin(), end = functionGroups.cend(); it != end; ++it) {
AbstractMetaFunctionList overloads;
QSet<QString> seenSignatures;
+ bool staticEncountered = false;
for (AbstractMetaFunction *func : it.value()) {
if (!func->isAssignmentOperator()
&& !func->usesRValueReferences()
@@ -460,6 +461,19 @@ void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext)
// But when a function is both in a class and inherited in a subclass,
// then we need to search through all subclasses and collect the new signatures.
overloads << getFunctionAndInheritedOverloads(func, &seenSignatures);
+ if (func->isStatic())
+ staticEncountered = true;
+ }
+ }
+ // PYSIDE-886: If the method does not have any static overloads declared
+ // in the class in question, remove all inherited static methods as setting
+ // METH_STATIC in that case can cause crashes for the instance methods.
+ // Manifested as crash when calling QPlainTextEdit::find() (clash with
+ // static QWidget::find(WId)).
+ if (!staticEncountered) {
+ for (int i = overloads.size() - 1; i >= 0; --i) {
+ if (overloads.at(i)->isStatic())
+ delete overloads.takeAt(i);
}
}