Skip to content

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

Merged
Carreau merged 1 commit intoipython:masterfrom
takluyver:i9784
Jul 25, 2016
Merged

Create a QApplication for inputhook if one doesn't already exist#9789
Carreau merged 1 commit intoipython:masterfrom
takluyver:i9784

Conversation

@takluyver
Copy link
Copy Markdown
Member

Closes gh-9784

@takluyver
Copy link
Copy Markdown
Member Author

See discussion on #9784 before merging this.

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

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
Copy Markdown
Member Author

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
Copy Markdown
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

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

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
Copy Markdown
Member Author

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
Copy Markdown
Contributor

@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 July 29, 2016 16:02
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.

3 participants