Is the 'okay' parameter of QWebView::loadFinished() ever false?
I'm using QWebView to display an HTML page that is local to my machine. My code looks something like this:
Code:
m_url = "file:///c:temp/foo.html";
connect(m_webView, SIGNAL(loadFinished(bool)), SLOT(onLoadFinished(bool)));
m_webView
->load
( QUrl(m_url
) );
.
.
.
void MyWindow::onLoadFinished(bool okay)
{
if ( ! okay )
{
QString errorMsg
( tr
("<html><body>An error occurred while trying to load %1.</body></html>").
arg(m_url
) );
m_webView->setHtml(errorMsg);
}
}
The problem is that 'okay' seems to always be true, even when:
- the file doesn't exist
- the file contains bad HTML
- the file contains no HTML
In a search of the Trolltech TaskTracker and googling, I didn't find any reports of this issue, so I'm thinking maybe there's something wrong with how I'm using QWebView. According to the docs, the boolean parameter of loadFinished() "will indicate whether the load was successful or any error occurred." Seems like at least one of the cases I listed above would elicit an error indication from loadFinished(), but that's not happening. Does anyone know if I'm doing something wrong or if this is just a bug in QWebView::loadFinished()?
Re: Is the 'okay' parameter of QWebView::loadFinished() ever false?
Based on the source code of WebKit I can tell you there are two cases where the signal will be emitted with a value of false.
Re: Is the 'okay' parameter of QWebView::loadFinished() ever false?
Hmm, FrameLoaderClientQt::dispatchDidFailLoad() and FrameLoaderClientQt::dispatchDidFailLoading() appear to be the only two places in the webkit source where the flag is set to false, but it doesn't appear that those functions are ever called (at least not within the webkit source). I guess I won't count on that flag being useful any time soon. :(
Re: Is the 'okay' parameter of QWebView::loadFinished() ever false?
They are probably called somewhere in the webkit core. And even if not, it doesn't mean they won't be called tomorrow.
Re: Is the 'okay' parameter of QWebView::loadFinished() ever false?
I'm developing an embeddead app where page reloads is supposed to be completely invisible (if contens is unchanged, of cause).
To set the url I:
web_view->setUpdatesEnabled(false);
web_view->load(QUrl(NewUrl));
Then on the load
void MainWindow::finishLoading(bool ok)
{
web_view->setUpdatesEnabled(true);
}
I can tell you that ok is ideed false now and then, I not sure why. Apperently it is called soon after with true. So I problaly need to only enable update if ok is true.
Maybe its some specifik errorcode from the server. It does not appear to be a timeout as it comes quite fast.
You right that missing files or fucked up html still generates ok=true. I guess it must be some specific errorcode from the server.
I know, need to do some counting on the setUpdatesEnabled