-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Prevent Qt4 from stopping the interpreter #1905
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
Conversation
Wow. That's kind of obnoxious of PyQt and PySide ::. This should definitely be tested on MS Windows: I'm not crazy about solving this problem with For Linux, at least, we could just check to the existence and validity of the |
I agree, starting a process is a bit heavy. |
@@ -23,6 +23,8 @@ | |||
|
|||
from qt4_compat import QtCore, QtGui, _getSaveFileName, __version__ | |||
|
|||
import subprocess |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor point -- this can probably be removed since it's no longer being used.
This is much better. Thanks for your patience on this -- I have one more suggestion. I think that the https://deptinfo-ensip.univ-poitiers.fr/ENS/pyside-docs/PySide/QtGui/QX11Info.html Maybe we check for the existence of that, and then do the |
Hi, I tried this;
I also removed the subprocess import. J. |
Hi, I used a regex to verify DISPLAY:
since: J. |
Sorry, I only have a non-X11 build of Qt4 on my Mac, so I can't test this. |
@mdehoon: It actually would be more valuable if you could test this with the native build of Qt4 on your Mac. In particular, it's an open question as to whether the method used here to determine if we're using an X11 Qt4 is correct or not. So if you wouldn't mind trying it with a native Qt4 build, that would be very helpful. |
It seems to work fine: With the native Qt4 build on my Mac,
returns False. |
Hi, I just tried hasattr(QtGui, "QX11Info") on windows with PyQt4, and it's OK too. J. |
Great. Merging. Thanks for the patch. |
Prevent Qt4 from stopping the interpreter
Hi,
This commit prevents Qt4 from stopping the interpreter:
If there's no X server available, or if you export DISPLAY="", and try to initialize a QApp, Qt4 stops:
It's a non-feature of Qt4 to not use exceptions to be lightweight.
But in python, that's not really the spirit, we'd expect a python backtrace, so here's what the patch does:
And it's more like the other backends do:
Regards.
(EDIT by @pelson: Added code blocks)