QApplication.notify exception?

Matic Kukovec <[email protected]>
Newsgroups gmane.comp.python.pyqt-pykde
Message-ID <VI1PR01MB5344040E751EA51019E93015D71C0@VI1PR01MB5344.eurprd01.prod.exchangelabs.com>
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

_______________________________________________
PyQt mailing list    [email protected]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.