Skip to content
This repository
Browse code

Cleanup

  • Loading branch information...
commit 9257fe3c93bb1f842246b64de8b0a78efaaa2a41 1 parent 353fe86
Matthew Mongeau authored September 23, 2011
2  spec/driver_spec.rb
@@ -142,7 +142,7 @@
142 142
       end
143 143
     end
144 144
 
145  
-    it "should render unsupported content types gracefully" do
  145
+    it "renders unsupported content types gracefully" do
146 146
       subject.visit("/")
147 147
       subject.body.should =~ /css/
148 148
     end
18  src/UnsupportedContentHandler.cpp
@@ -12,12 +12,20 @@ UnsupportedContentHandler::UnsupportedContentHandler(WebPage *page, QNetworkRepl
12 12
 void UnsupportedContentHandler::handleUnsupportedContent() {
13 13
   QVariant contentMimeType = m_reply->header(QNetworkRequest::ContentTypeHeader);
14 14
   if(!contentMimeType.isNull()) {
  15
+    this->loadUnsupportedContent();
  16
+    this->finish(true);
  17
+  } else {
  18
+    this->finish(false);
  19
+  }
  20
+  this->deleteLater();
  21
+}
  22
+
  23
+void UnsupportedContentHandler::loadUnsupportedContent() {
15 24
     QByteArray text = m_reply->readAll();
16 25
     m_page->mainFrame()->setContent(text, QString("text/plain"), m_reply->url());
  26
+}
  27
+
  28
+void UnsupportedContentHandler::finish(bool success) {
17 29
     connect(m_page, SIGNAL(loadFinished(bool)), m_page, SLOT(loadFinished(bool)));
18  
-    m_page->loadFinished(true);
19  
-  } else {
20  
-    connect(m_page, SIGNAL(loadFinished(bool)), m_page, SLOT(loadFinished(bool)));
21  
-    m_page->loadFinished(false);
22  
-  }
  30
+    m_page->loadFinished(success);
23 31
 }
2  src/UnsupportedContentHandler.h
@@ -13,4 +13,6 @@ class UnsupportedContentHandler : public QObject {
13 13
   private:
14 14
     WebPage *m_page;
15 15
     QNetworkReply *m_reply;
  16
+    void loadUnsupportedContent();
  17
+    void finish(bool success);
16 18
 };

0 notes on commit 9257fe3

Joe Ferris

Can you reverse the if clause so that we don't need an "if not then else?"

Please sign in to comment.
Something went wrong with that request. Please try again.