Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not call setQuitOnLastWindowClosed() on a QCoreApplication #791

Merged
merged 1 commit into from
Oct 25, 2021

Conversation

stukowski
Copy link
Contributor

Fixes the following error.

Notebook cell:

%gui qt
from PyQt5 import QtCore
app = QtCore.QCoreApplication([''])

Kernel error:

Traceback (most recent call last):
  File "c:\users\astuk\appdata\local\programs\python\python38\lib\site-packages\tornado\ioloop.py", line 741, in _run_callback
    ret = callback()
  File "c:\users\astuk\appdata\local\programs\python\python38\lib\site-packages\ipykernel\kernelbase.py", line 402, in advance_eventloop
    eventloop(self)
  File "c:\users\astuk\appdata\local\programs\python\python38\lib\site-packages\ipykernel\eventloops.py", line 130, in loop_qt5
    return loop_qt4(kernel)
  File "c:\users\astuk\appdata\local\programs\python\python38\lib\site-packages\ipykernel\eventloops.py", line 120, in loop_qt4
    kernel.app.setQuitOnLastWindowClosed(False)
AttributeError: 'QCoreApplication' object has no attribute 'setQuitOnLastWindowClosed'

loop_qt4() currently expects the get_app_qt4() function to always return a QApplication object (or a QGuiApplication in Qt5). This is not a valid assumption. The user may be creating just a QCoreApplication base class instance to run Qt event processing in the backend, never displaying any Qt windows/widgets. Non-UI Qt applications do not support the setQuitOnLastWindowClosed() method.

@blink1073 blink1073 added the bug label Oct 25, 2021
@blink1073 blink1073 added this to the 6.4 milestone Oct 25, 2021
Copy link
Contributor

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@blink1073 blink1073 merged commit 7268d55 into ipython:master Oct 25, 2021
@stukowski stukowski deleted the patch-2 branch October 25, 2021 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants