Unsolved Close QWebEngineProcess.exe
-
Hello, Qt community. I was faced with a problem, that after closing QDialog with web content, the QWebEngineProcess.exe process is not closing. Here is a fast example
#include <QApplication> #include <QWebEngineView> #include <QWebEngineSettings> #include <QDialog> #include <QMainWindow> #include <QLayout> #include <QtGui> #include <QPushButton> class Dialog : public QDialog { public: Dialog() : QDialog(nullptr) { resize(512, 512); setAttribute(Qt::WA_DeleteOnClose); auto verticalLayout = new QVBoxLayout(this); verticalLayout->setSpacing(0); verticalLayout->setContentsMargins(0, 0, 0, 0); m_webView = new QWebEngineView(this); verticalLayout->addWidget(m_webView); } void openPage(const QUrl& url) { m_webView->setUrl(url); } private: QWebEngineView* m_webView; }; class MainWindow : public QMainWindow { public: MainWindow() : QMainWindow(nullptr) { resize(512, 512); QPushButton* btn = new QPushButton("open web dialog", this); connect(btn, &QPushButton::clicked, [this] () { if (m_dialog == nullptr) { m_dialog = new Dialog(); m_dialog->openPage(QUrl("https://www.qt.io")); m_dialog->show(); } }); } private: QPointer<Dialog> m_dialog; }; int main(int argc, char *argv[]) { QCoreApplication::setOrganizationName("QtExamples"); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication app(argc, argv); MainWindow window; window.show(); return app.exec(); }
I'm expecting, that after Dialog closed, QWebEngineProcess.exe will be closed too, because I'm not using webengine anymore. P.S. During opening WebPage, I have 2 QWebEngineProcess.exe. One is disappearing, but the second one left
Will appreciate any help/ideas!
-
@Holiday
You're not supposed to worry about this. Qt WebEngine spawns various instances of that external WebEngine process which come and go to do its work, as you have seen. It seems to leave at least one around once it has spawned it (efficiency, re-use, whatever), and that closes I think when your application exits. I don't know of an interface available to force it to close. You would have to do something like an OS look-up of running processes and OS kill it, which is at least "not documented". -
I have certain reasons to close this process. I tried to kill this process, but it recreates another instance before terminating. So I always see one.
-
@Holiday
Doesn't surprise me! You could look around the sources to understand what is going on.