Commit c88e3539 authored by yael.aharon@nokia.com's avatar yael.aharon@nokia.com

2009-06-19 Yael Aharon <yael.aharon@nokia.com>

        Reviewed by Holger Freyther.

        https://bugs.webkit.org/show_bug.cgi?id=26556

        Fix a crash in case that the QNetworkReply::readReady signal is
        "stuck" in deferred mode due to JavaScript alert, and in the meantime,
        QNetworkreply::finished signal is received and processed before
        QNetworkReply::readReady is processed.

        * manual-tests/qt/unload-alert.html: Added.
        * platform/network/qt/QNetworkReplyHandler.cpp:
        * platform/network/qt/QNetworkReplyHandler.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@44934 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e8a2267b
2009-06-19 Yael Aharon <yael.aharon@nokia.com>
Reviewed by Holger Freyther.
https://bugs.webkit.org/show_bug.cgi?id=26556
Fix a crash in case that the QNetworkReply::readReady signal is
"stuck" in deferred mode due to JavaScript alert, and in the meantime,
QNetworkreply::finished signal is received and processed before
QNetworkReply::readReady is processed.
* manual-tests/qt/unload-alert.html: Added.
* platform/network/qt/QNetworkReplyHandler.cpp:
(WebCore::QNetworkReplyHandler::setLoadMode):
(WebCore::QNetworkReplyHandler::finish):
(WebCore::QNetworkReplyHandler::sendResponseIfNeeded):
(WebCore::QNetworkReplyHandler::forwardData):
(WebCore::QNetworkReplyHandler::start):
(WebCore::QNetworkReplyHandler::sendQueuedItems):
* platform/network/qt/QNetworkReplyHandler.h:
(WebCore::QNetworkReplyHandler::):
2009-06-22 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
Fix the Qt build.
......
<html>
<head>
</head>
<body onunload="alert('goodbye');">
Reload me twice ensuring that this didn't result in a crash. Test added due to
bug <a href="https://bugs.webkit.org/show_bug.cgi?id=26556">@25556</a>
</body>
</html>
......@@ -162,9 +162,21 @@ QNetworkReplyHandler::QNetworkReplyHandler(ResourceHandle* handle, LoadMode load
void QNetworkReplyHandler::setLoadMode(LoadMode mode)
{
m_loadMode = mode;
if (m_loadMode == LoadNormal)
sendQueuedItems();
// https://bugs.webkit.org/show_bug.cgi?id=26556
// We cannot call sendQueuedItems() from here, because the signal that
// caused us to get into deferred mode, might not be processed yet.
switch (mode) {
case LoadNormal:
m_loadMode = LoadResuming;
emit processQueuedItems();
break;
case LoadDeferred:
m_loadMode = LoadDeferred;
break;
case LoadResuming:
Q_ASSERT(0); // should never happen
break;
};
}
void QNetworkReplyHandler::abort()
......@@ -194,8 +206,8 @@ QNetworkReply* QNetworkReplyHandler::release()
void QNetworkReplyHandler::finish()
{
m_shouldFinish = (m_loadMode == LoadDeferred);
if (m_loadMode == LoadDeferred)
m_shouldFinish = (m_loadMode != LoadNormal);
if (m_shouldFinish)
return;
sendResponseIfNeeded();
......@@ -230,8 +242,8 @@ void QNetworkReplyHandler::finish()
void QNetworkReplyHandler::sendResponseIfNeeded()
{
m_shouldSendResponse = (m_loadMode == LoadDeferred);
if (m_loadMode == LoadDeferred)
m_shouldSendResponse = (m_loadMode != LoadNormal);
if (m_shouldSendResponse)
return;
if (m_responseSent || !m_resourceHandle)
......@@ -314,8 +326,8 @@ void QNetworkReplyHandler::sendResponseIfNeeded()
void QNetworkReplyHandler::forwardData()
{
m_shouldForwardData = (m_loadMode == LoadDeferred);
if (m_loadMode == LoadDeferred)
m_shouldForwardData = (m_loadMode != LoadNormal);
if (m_shouldForwardData)
return;
sendResponseIfNeeded();
......@@ -399,6 +411,8 @@ void QNetworkReplyHandler::start()
connect(m_reply, SIGNAL(readyRead()),
this, SLOT(forwardData()), Qt::QueuedConnection);
connect(this, SIGNAL(processQueuedItems()),
this, SLOT(sendQueuedItems()), Qt::QueuedConnection);
}
void QNetworkReplyHandler::resetState()
......@@ -413,7 +427,9 @@ void QNetworkReplyHandler::resetState()
void QNetworkReplyHandler::sendQueuedItems()
{
Q_ASSERT(m_loadMode == LoadNormal);
if (m_loadMode != LoadResuming)
return;
m_loadMode = LoadNormal;
if (m_shouldStart)
start();
......
......@@ -43,7 +43,8 @@ class QNetworkReplyHandler : public QObject
public:
enum LoadMode {
LoadNormal,
LoadDeferred
LoadDeferred,
LoadResuming
};
QNetworkReplyHandler(ResourceHandle *handle, LoadMode);
......@@ -55,15 +56,18 @@ public:
QNetworkReply* release();
signals:
void processQueuedItems();
private slots:
void finish();
void sendResponseIfNeeded();
void forwardData();
void sendQueuedItems();
private:
void start();
void resetState();
void sendQueuedItems();
QNetworkReply* m_reply;
ResourceHandle* m_resourceHandle;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment