I am using QWebPage class to load a page in background in my QT application.
Whenever it emits “repaintReqest”, I try to render the contents of main frame onto a painter (QImage)
using code like below:
QWebpage page;
QImage m_image
onRepaintRequest(){
QMutexLocker locker(&mutex);
QPainter painter(m_image);
page.mainFrame()->documentElement().render(&painter)
}
My application randomly hangs at render function call sometimes.
I ensure that m_image is not accessed by any other thread..
What could be the reason for this behavior?
Edit:: If I call render on main frame while QWebPage is updating it internally, can that cause hang? This is something QT should handle internally.
why
page.mainFrame()->documentElement().render(&painter)rather thanpage.mainFrame()->render(&painter)?As said in the doc, use the
void QWebFrame::render ( QPainter * painter, const QRegion & clip )form to avoid rendering endless loop.