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

Create a QApplication for inputhook if one doesn't already exist #9789

Merged
merged 1 commit into from Jul 25, 2016

Conversation

takluyver
Copy link
Member

@takluyver takluyver commented Jul 21, 2016

Closes gh-9784

@takluyver
Copy link
Member Author

takluyver commented Jul 21, 2016

See discussion on #9784 before merging this.

app = QtCore.QCoreApplication.instance()
if not app:
return
Copy link
Member

@Carreau Carreau Jul 21, 2016

Choose a reason for hiding this comment

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

Want to drop a DeprecationWarning/(UserWarning maybe) here if App does not exists ? so that we can remove it at some point later?

Copy link
Member Author

@takluyver takluyver Jul 21, 2016

Choose a reason for hiding this comment

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

If we do decide to keep it in place, I wouldn't really consider it deprecated.

Copy link
Member

@Carreau Carreau Jul 21, 2016

Choose a reason for hiding this comment

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

I think we broke the use case in 5.0, and I'm fine restoring the behavior in next minor/patch version {especially since LTS]
I don't think in the long run we should create the App if it does not exists.

So I would reinstate it to not break user-code/habits. But warn about it, and remove it in the Py3Only-branch.

@Carreau Carreau added this to the 5.1 milestone Jul 22, 2016
@Carreau Carreau merged commit f4d0d99 into ipython:master Jul 25, 2016
@@ -1,10 +1,15 @@
import sys
from IPython.external.qt_for_kernel import QtCore, QtGui

# If we create a QApplication, keep a reference to it so that it doesn't get
# garbage collected.
_appref = None
Copy link
Contributor

@tacaswell tacaswell Jul 29, 2016

Choose a reason for hiding this comment

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

90% sure that pyqt/pyside already do this.

Copy link
Member Author

@takluyver takluyver Jul 29, 2016

Choose a reason for hiding this comment

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

At least one of the options we support seemingly doesn't - I tried without it and things went wrong. I can't remember which one I was testing with, though.

@tacaswell
Copy link
Contributor

tacaswell commented Jul 29, 2016

@Carreau I disagree about not creating this the App. If the user has asked to use Qt event loop integration, then clearly they want to use Qt 😉 .

The qApp is a enforced-by-segfault singleton at the c++ level (the official line is creating more than one QApplication in the same process is undefined behavior) so all libraries that need a qApp need to go through this 'get the global if None create' dance (mpl does it here )

Having IPython do this as part of the integration is a big convenience for users.

@takluyver takluyver deleted the i9784 branch Jul 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants