It\'s not the first time I am getting the RuntimeError: underlying C/C++ object has been deleted. I\'ve solved it many times altering my code in a random but in
How to test if the underlying object exists?
How to avoid it?
You could use:
try: someObject.objectName()
except RuntimeError: return False
The .objectName() test is an arbitrary interrogation which all valid QObjects should easily pass.
If they fail, they'll throw a RuntimeError which is an indication they are invalid.
In this crude example we absorb the RuntimeError and instead return false.