Details
-
Suggestion
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.9.3
Description
It seems like WebEngineContext is designed in such a way that it cannot be used ever again after QCoreApplication is destroyed once.
In our particular case, we are trying to do a restartable application (based on the pattern here https://wiki.qt.io/How_to_make_an_Application_restartable) , so we destroy and recreate QCoreApplication (or rather QApplication, is it is a widget app). But, when then we try to recreate QWebEngineView, the application crashes with a nullptr dereference.
Inspecting the source code for WebEngineContext, in particular the handling of the singleton (::current()), the variable "s_destroyed" and the call to qAddPostRoutine(destroyContext) , leads us to beleave the WebEngineContext::current() will only return a valid pointer during the first creation of QCoreApplication. Once that first instance of QCoreApplication is destroyed, 'destroyContext' will be called, which will set 's_destroyed' to true. And from there onwards ::current() will return nullptr.
If this is an intended restriction on QWebEngine, then it should be documented clearly in the documentation of the class. (I couldn't see it mentioned anywhere)