[PyQt] QApplication.notify exception?

Matic Kukovec kukovecmatic at hotmail.com
Sun May 26 21:37:38 BST 2019


Hi guys,

I have an application that runs without a problem on Windows, but on Linux it shows this message on exit:

Qt has caught an exception thrown from an event handler. Throwing
exceptions from an event handler is not supported in Qt.
You must not let any exception whatsoever propagate through Qt code.
If that is not possible, in Qt 5 you must at least reimplement
QCoreApplication::notify() and catch all exceptions there.

I added an exception handler to a sub-classed QApplication like so:
class MyApplication(data.QApplication):
            def notify(self, obj, event):
                try:
                    return super().notify(obj, event)
                except:
                    print("Unexpected Error")
                    traceback.print_exc()
                    sys.stdout.flush()
                    return False
and it prints:

Unexpected Error
Traceback (most recent call last):
  File "myfile.py", line X, in notify
    return super().notify(obj, event)
RuntimeError: wrapped C/C++ object of type QObject has been deleted

Any ideas of how to solve this problem?

I'm on Lubuntu x86, Python 3.7, PyQt5.12.2.

Thanks,
Matic


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190526/22ec9a13/attachment.html>


More information about the PyQt mailing list