Details
Description
When adding items to a combo box with userData, a segmentation fault can occur if the object implements ``__getitem__`` in a certain way. Example:
from PySide2.QtWidgets import QApplication, QComboBox from PySide2.QtCore import QObject class Test(object): def __getitem__(self, key): raise KeyError("HEY") app = QApplication(['']) combo = QComboBox() combo.addItem('a', userData=Test()) print(combo.itemData(0))
This code leads to a segmentation fault - here's an extract from the MacOS X report:
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 QtCore.cpython-36m-darwin.so 0x00000001060a5bbd QVariant_isStringList(_object*) + 29
1 QtCore.cpython-36m-darwin.so 0x000000010609e5cf PySequence_PythonToCpp_QVariant(_object*, void*) + 31
2 QtWidgets.cpython-36m-darwin.so 0x0000000101eaa00c Sbk_QComboBoxFunc_addItem(_object*, _object*, _object*) + 604
3 libpython3.6m.dylib 0x00000001013fc837 _PyCFunction_FastCallDict + 183
4 libpython3.6m.dylib 0x00000001013fca4b _PyCFunction_FastCallKeywords + 75
5 libpython3.6m.dylib 0x0000000101480597 call_function + 439
6 libpython3.6m.dylib 0x000000010147cf78 _PyEval_EvalFrameDefault + 25096
7 libpython3.6m.dylib 0x00000001014813dc _PyEval_EvalCodeWithName + 3436
8 libpython3.6m.dylib 0x0000000101476ca4 PyEval_EvalCode + 100
9 libpython3.6m.dylib 0x00000001014ac841 PyRun_FileExFlags + 209
10 libpython3.6m.dylib 0x00000001014ac0ee PyRun_SimpleFileExFlags + 846
11 libpython3.6m.dylib 0x00000001014c5a96 Py_Main + 3526
12 python 0x000000010139adf8 main + 232
13 libdyld.dylib 0x00007fff70753015 start + 1
Attachments
Issue Links
- relates to
-
PYSIDE-726 If you give a QComboBox a python instance that implements the sequence protocall, you get a list back
-
- Closed
-