Attempt to delete CallTipWidget after the C/C++ object has been deleted
See original GitHub issueWhen shutting down an application which has an embedded QtConsole, I get the following error with v5.2.0, which does not occur in v5.1.1.
RuntimeError Traceback (most recent call last)
~/opt/miniconda3/envs/py38/lib/python3.8/site-packages/qtconsole/call_tip_widget.py in <lambda>()
21 assert isinstance(text_edit, (QtWidgets.QTextEdit, QtWidgets.QPlainTextEdit))
22 super().__init__(None, QtCore.Qt.ToolTip)
---> 23 text_edit.destroyed.connect(lambda: self.deleteLater())
24
25 self._hide_timer = QtCore.QBasicTimer()
RuntimeError: wrapped C/C++ object of type CallTipWidget has been deleted
It appears to happen when calling the QApplication quit
function, so I guess the standard PyQt shutdown process doesn’t guarantee that the C/C++ ToolTip widget is destroyed after the QTextEdit widget. I can get around this by explicitly closing the console widget, which is a sub-class of FrontendWidget, before calling quit
.
I am raising this as an issue because I wanted to find out if this was the expected behavior. Are you assuming that the FrontendWidget is always explicitly closed when shutting down an application using QtConsole? That wasn’t necessary before the change. It might be possible to prevent this by subclassing the CallTipWidget deleteLater
function to catch this exception, which would ensure that other applications don’t break.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
That was my fault for listing the traceback that was generated by the error. It still doesn’t make sense to me that the traceback points to
CallTipWidget.__init__
, whereas the problem occurs when destroying it. I will submit a new PR shortly.Sorry, I thought this could be solved with a simple try/except.
Looks good to me. My only recommendation is to catch
RuntimeError
instead of leaving a bareexcept
there. Could you make a pull request for it? Thanks!