-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Crash when launching app using QQmlApplicationEngine from PyQt5 #63
Comments
This was with:
all from Ubuntu packages on Kubuntu 15.10 with backports enabled. |
Perhaps obvious, but the crash does not happen with |
Yeah, so right now PyOtherSide assumes that it "owns" the Python interpreter, and initializes the Python interpreter, etc.. -- if you want to use it with PyQt, you have to modify PyOtherSide to not take ownership of the Python interpreter (and in that case, it won't work from a C++ application). At least this call you have to remove (among other things, I haven't tested it): https://github.com/thp/pyotherside/blob/master/src/qpython_priv.cpp#L503 Part of the point of PyOtherSide is that you don't need to load the Python interpreter when your QML UI comes up, and only load Python and its modules asynchronously afterwards -- if you use PyQt (which means you load Python and PyQt before loading Qt and your QML UI), you might just as well only use PyQt's support from QML and not use PyOtherSide. |
Yes, I guessed the problem was something like this. But is there really no way to modify/improve For now I'll just use a Qt C++ "launcher" application to load the QML instead, it's not much of a problem. The reason I tried to convert it to PyQt was that we're a mostly Python shop, we had a dependency on PyQt in other parts of this system anyway (it's a set of applications for controlling a mineral analysis machine), and that with the launcher as a Python script, we wouldn't have to compile anything. So I was just a little surprised that it crashed so hard :) I know the point of Anyway, I'll close this issue if there's really no way to make |
Thinking some more, I guess it's just a CPython limitation that you can't have two interpreters within the same process space without them trampling on each other? If so, then I guess there's nothing to do, short of making Maybe a short note could be added to the docs that launching a QML app that uses |
Note that you can also use |
Yep, I know Did not know about the new |
I ran to this page by having the same problem on a small use case: I found out that passing the QApplication as parent to the QQmlApplicationEngine avoid having a I still have some messages clearly indicating that some Qt object are not destructed in the right order. But at least it seems to avoid the segmentation fault. Note : I use PyQt5.6 and Python 3.5 |
I get a segmentation fault if I launch a QML application that makes use of the
Python
component by using QQmlApplicationEngine from a PyQt5 application. The same does not happen if I launch it from the equivalent C++ application.Minimal test case:
test.py - The Python launcher application:
test.cpp - Same as above, but this time in C++:
test.pro - To build main.cpp:
test.qml - The test QML application:
Launching using C++ ⇒ OK
This works fine, the window is shown and there's no crash:
Launching using Python ⇒ CRASH
This gives a segmentation fault:
The backtrace is:
If I just remove the
Python
component, the crash disappears.Sorry for the lack of symbols in
pyotherside
(nopyotherside-dbg
package on Ubuntu), but I hope the crash should be reproducible from this description.The text was updated successfully, but these errors were encountered: