Details
Description
If your QML application binds to a property that raises an exception, the application crashes with a segfault. Is there any way this could be handled more gracefully, either on the python side or on the QML side?
As a simple example, you can simply bind to a property like:
@Property(str, constant=True) def my_property(self): raise ValueError
As soon as QML needs to read that property, python will raise the exception, and the app will crash with a segfault. In order to avoid this, you could wrap every single property in a try-except that scrubs all exceptions, but that would be a mess on a large existing project. Is there somewhere that the @Property decorator could be modified to handle exceptions? And by "handle exceptions" here, I don't mean do anything particularly special. That would be up to the developer, but some uncontroversial thing like just letting python print a traceback before crashing would be an improvement, otherwise the user doesn't get any feedback about what happened and it's hard for a developer to track down.
In fact, even just printing an error in the QML console would work.
Attachments
For Gerrit Dashboard: PYSIDE-3067 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
640585,10 | libshiboken: Use PyErr_SetRaisedException() for unraisable exceptions | dev | pyside/pyside-setup | Status: NEW | 0 | 0 |
640586,13 | libshiboken: Add utility class for stashing Python errors | dev | pyside/pyside-setup | Status: NEW | 0 | 0 |
636119,9 | Fix crash when entering a Qt message handler with a Python error set | dev | pyside/pyside-setup | Status: MERGED | +2 | +1 |
640769,8 | libshiboken: Introduce define for old PyErr_ API | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
641221,2 | Fix crash when entering a Qt message handler with a Python error set | 6.9 | pyside/pyside-setup | Status: MERGED | +2 | 0 |