Details
-
Bug
-
Resolution: Won't Do
-
P3: Somewhat important
-
None
-
5.2.1
-
None
Description
I experienced a strange behaviour of QWebView when writing a web crawler application. It required a lot of effort to find out what is happening.
The application does the following:
1. Create a QWebView object and connect a slot to the loadingFinished signal.
2. In the mention slot (and ok==true) it searches for an image and writes it geometry to the debug console. e.g. :
webView.page()->mainFrame()->findFirstElement("img[alt][width][height][src$='.jpg']").geometry();
3. Call setUrl() using an existing webpage URL.
The first time this works fine and the expected geometry is printed. The second time (and all succeeding retries with the same URL) it find the right img element (with correct src) but prints an invalid geometry (0,0 0x0).
When comparing
webView.page()->totalBytes()
to
webView.page()->bytesReceived()
in the slot, the numbers always are equal on the first (successful) try while bytesReceived() is smaller than totalBytes() on all failed tries.
When changing the loadingFinished->slot connection type from DirectConnection to QueuedConnection the problem disappears and proper geometries are found on every try.
It seems to me that the loadingFinished signal is emitted to early (before the QWebView DOM is setup properly) if QWebView can satisfy the URL load request more quickly using some cache.