Reputation: 686
I have an application that uses Qt WebEngine. But I found that after closing my application or after crashing it "Qtwebengineprocess" still stays on. My app is too big to show it here, but here is a little example which also demostrates the problem:
#include <QApplication>
#include <QWebEngineView>
#include <QProcess>
#include <QTimer>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QWebEngineView* viewer = new QWebEngineView(NULL);
viewer->show();
viewer->load(QUrl("https://www.telegraph.co.uk/content/dam/Pets/spark/royal-canin/tabby-kitten-small.jpg?imwidth=1400"));
QTimer::singleShot(2000, []() {
exit(-1);
});
app.exec();
delete viewer;
return 0;
}
Did I forget to set up some thing? Or this is a Qt bug? Thanks in advance.
UPD: Qt 5.11, Win10
Upvotes: 3
Views: 5155
Reputation: 3493
I found actual issue and solution - here . This is Qt 5.11 bug that describes exactly this problem.
And one of the comments had solution that worked for me:
When running with QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
at the top of the main() function, I'm observing that the qtwebengine process closes correctly,
both when stopping the debugger and when the release exe crashes.
Just added that line before creation of my qApp
and saw no crash whatsoever. Of course this comes with benefits and disadvantages of using ANGLE vs dynamic GPU on Qt, more details here.
Upvotes: 2
Reputation: 681
This seems to be a bug in PyQt 5.11 and above. After reinstalling my OS and installing the latest version of PyQt (5.11.3) I experienced this and other issues with QWebEngineView not resizing properly in layouts. Downgraded to PyQt 5.10.1 and everything ran properly again. If using Python, just run:
pip uninstall PyQt5
pip install PyQt5==5.10.1
Upvotes: 2
Reputation: 4602
With reference to this post , when exit()
is called in main()
, no destructor will be called for locally scoped objects! exit()
does not return.
Any code placed after app.exec()
, (in your case delete viewer;
), would be executed ONLY after main eventloop quits/exits and returns to caller, Your timer is calling (stdlib) exit()
from within main loop, which means: you are exiting execution without return to caller, AND, none of your code placed AFTER app.exec()
would be executed, if you want your code to run correctly and execute delete viewer;
, then timer should quit main event loop thus you need to call app.quit()
or app.exit(-1)
.
Upvotes: 1