Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Does QWebEnginePage::load() start a new event loop internally or it just calls processEvents() ?
comy last edited by comy
After debugging an application crash, I have found that QWebEnginePage::load() internally processes queued events and causes unexpected re-entrancy in my code.
I have modified my code to handle reentrancy, but there are parts of my code that invoke deleteLater(). To be sure that some objects will not get deleted while within QWebEnginePage::load(), I would like to know if that method starts internally an event loop or it just calls processEvents() ?
Thanks in advance.
JonB last edited by
I would like to know if that method starts internally an event loop or it just calls processEvents().
Having recently struggled with
QWebEnginePageand the freeing of objects. My confused-and-without-guarantee finding was that
thingies->deleteLater()did not free them until I returned to the main Qt event loop. Just like calling only
processEvents(). Which for me was just what I did not want, but I think for you it is what you'd like.
As per https://doc.qt.io/qt-5/qcoreapplication.html#processEvents, these are DeferredDelete events.
I think you know that, and from the way you phrased your question you know more than I! So I should like to ask you a question!
When you say
start a new event loop internally or it just calls
and the docs say
In the event that you are running a local loop which calls this function continuously, without an event loop
I don't understand just what is meant beyond calling
processEvents()? What is/how do you write a "new local event loop" instead?
comy last edited by
@JonB Starting a new local event loop is done by executing QEventLoop::exec(). That is what for example QDialog::exec() does. It blocks and performs event processing, where processEvents just processes what is in the queue and returns.
I hope somebody can confirm to me that this is not the case with QWebEnginePage::load(), for which I know it does process events, just not sure if by starting event loop or with call to processEvents().
JonB last edited by JonB
@JonB Starting a new local event loop is done by executing QEventLoop::exec().
Oh I see, just
QEventLoop::exec(). Yes, I had tried that. According to me it made no difference, and
QWebEnginestuff still didn't free till execution got back to my top-level Qt event loop. Didn't understand why, your mileage may vary :)