Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.12.0
-
None
Description
Sometimes the pointer to the QWebEngineView inside the QWebEnginePage::runJavaScript callback is undefined. This behavior occurs when the JavaScript is running longer than the QWebEngineView lives. To reproduce, execute an endless loop in the JavaScript callback and than delete the QWebEngineView i.e. by closing the tab. By deleting the view, the JavaScript is aborted and the callback is triggered.
QWebEngineView* v = new QWebEngineView();
v->page()->runJavaScript("while(true){}",
QWebEngineScript::ApplicationWorld,
[v](const QVariant& data)
);
For me this is unexpected, because the JavaScript lives inside the page and the page inside the WebEngineView.
Perhaps it is possible to introduce a similer concept like in the connect function of Qt. The connect function ensures that the sender and receiver are alive when the callback is triggered.
connect(sender, &Sender::valueChanged, receiver, &Receiver::updateValue );