Hi I am trying to write a new reduction GUI for the Workbench in Python with Qt5 and I am running in some strange problem.
I have a QTreeView which should show a Tree of Scans, it is filled by a custom QAbstractItemModel.
This is working fine as long as I have less than around 10.000 objects in the Tree, if I have more I get an error:
“RuntimeError: wrapped C/C++ object of type QSpinBox has been deleted”
on the next QtObject which comes after filling the Model.
It does not seem to be a Garbage collection problem, since I can change the QtObject to anything and I get the same error (even on objects that will have a reference for sure like the QSpinBox).
Before I sub-classed QAbstractItemModel I used QStandardItemModel.
I had the same problem, but earlier since I had a lot of QStandardItems.
This was running fine outside of Mantid, even with much more Objects.
It also does not matter if I do incremental filling of the model, or fill it completely at creation.
So I am wondering if there is anything special in the Workbench that limits the number of QtObjects?
I could probably write something with uses fetchmore to get less objects, but that would prevent the user from being able to select all items.
Thanks for your help.
You are right, it is a garbage collection problem. Somehow my whole window gets garbage collected, I checked the list of the collected objects.
It just appears at high numbers because garbage collection is triggered.
If it is turned off it works.
Something seems to be wrong right at the creation of the Mainwindow object, because this is in the garbage collection:
<DNSReduction.DNSReductionGUI.DNSReductionGUI object at 0x000000002EBC7CA8>
the instance is created here: