How to manage the lifecycle of a lambda function in QWebEnginePage::runJavaScript method
Unsolved
QtWebEngine
-
wrote on 13 Feb 2018, 08:01 last edited by
QWebEngineView webEngineView; //... webEngineView->page()->runJavaScript("...", [this](const QVariant &v) { this->f(); });
The problem is that sometimes 'this' is destructed when the lambda function is called. Suppose 'this' is derived from QObject, how can we ensure that 'this' is valid when the lambda function is called? For example when using QObject::connect when we specify a context for lambd function, and when the destination object is destroyed the connection is disconnected automatically.
1/1