Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mhoran/capybara-webkit
...
head fork: mhoran/capybara-webkit
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Commits on Dec 06, 2012
@mhoran Emit loadStarted and pageFinished on WebPage state change
Instead of emitting loadStarted when a reply is created and pageFinished
when all pending replies have finished, emit these signals when the
corresponding WebPage events fire.
b28452e
@mhoran Don't disconnect loadFinished in UnsupportedContentHandler
WebPage::setContent will cause the loadFinished signal to fire, so
there's no need to call loadFinished if the signal is connected.
2eb38b3
View
4 src/PageLoadingCommand.cpp
@@ -9,13 +9,13 @@ PageLoadingCommand::PageLoadingCommand(Command *command, WebPageManager *manager
m_pageLoadingFromCommand = false;
m_pageSuccess = true;
m_pendingResponse = NULL;
- connect(m_manager, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
- connect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
}
void PageLoadingCommand::start() {
m_manager->logger() << "Started" << m_command->toString();
connect(m_command, SIGNAL(finished(Response *)), this, SLOT(commandFinished(Response *)));
+ connect(m_manager, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
+ connect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
m_command->start();
};
View
3  src/UnsupportedContentHandler.cpp
@@ -11,16 +11,13 @@ void UnsupportedContentHandler::renderNonHtmlContent() {
QByteArray text = m_reply->readAll();
m_page->mainFrame()->setContent(text, QString("text/plain"), m_reply->url());
m_page->unsupportedContentFinishedReply(m_reply);
- m_page->loadFinished(true);
this->deleteLater();
}
void UnsupportedContentHandler::waitForReplyToFinish() {
connect(m_reply, SIGNAL(finished()), this, SLOT(replyFinished()));
- disconnect(m_page, SIGNAL(loadFinished(bool)), m_page, SLOT(loadFinished(bool)));
}
void UnsupportedContentHandler::replyFinished() {
renderNonHtmlContent();
- connect(m_page, SIGNAL(loadFinished(bool)), m_page, SLOT(loadFinished(bool)));
}
View
8 src/WebPageManager.cpp
@@ -45,6 +45,7 @@ void WebPageManager::emitLoadStarted() {
logger() << "Load started";
emit loadStarted();
}
+ m_started += qobject_cast<WebPage *>(sender());
}
void WebPageManager::requestCreated(QByteArray &url, QNetworkReply *reply) {
@@ -53,7 +54,6 @@ void WebPageManager::requestCreated(QByteArray &url, QNetworkReply *reply) {
replyFinished(reply);
else {
connect(reply, SIGNAL(finished()), SLOT(handleReplyFinished()));
- m_started += reply;
}
}
@@ -66,15 +66,11 @@ void WebPageManager::handleReplyFinished() {
void WebPageManager::replyFinished(QNetworkReply *reply) {
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
logger() << "Received" << status << "from" << reply->url().toString();
- m_started.remove(reply);
- logger() << m_started.size() << "requests remaining";
- if (m_started.empty() && !m_success) {
- emitPageFinished();
- }
}
void WebPageManager::setPageStatus(bool success) {
logger() << "Page finished with" << success;
+ m_started.remove(qobject_cast<WebPage *>(sender()));
m_success = success && m_success;
if (m_started.empty()) {
emitPageFinished();
View
2  src/WebPageManager.h
@@ -49,7 +49,7 @@ class WebPageManager : public QObject {
WebPage *m_currentPage;
bool m_ignoreSslErrors;
NetworkCookieJar *m_cookieJar;
- QSet<QNetworkReply*> m_started;
+ QSet<WebPage *> m_started;
bool m_success;
bool m_loggingEnabled;
QString *m_ignoredOutput;

No commit comments for this range

Something went wrong with that request. Please try again.