diff ui/downloader.cpp @ 76:63b79d135631

Remove QTextStream usage. The QTextStream usage in this way caused a segmentation fault on Windows
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 19 Mar 2014 16:33:25 +0000
parents 7e304573ebd1
children 17e1c8f37d72
line wrap: on
line diff
--- a/ui/downloader.cpp	Wed Mar 19 15:36:35 2014 +0000
+++ b/ui/downloader.cpp	Wed Mar 19 16:33:25 2014 +0000
@@ -8,7 +8,6 @@
 #include <QDir>
 #include <QDebug>
 #include <QStandardPaths>
-#include <QTextStream>
 #include <QLocale>
 #include <QSaveFile>
 
@@ -68,7 +67,7 @@
     int bodyStart = data->indexOf("\r\n\r\n");
     QMap<QString, QString> retval;
     QByteArray headers;
-    QTextStream responseStream(&headers);
+    QString response(*data);
     if (bodyStart == -1) {
         qDebug() << "Could not find header end.";
         emit error(tr("Invalid response"),
@@ -80,12 +79,8 @@
     headers = data->left(bodyStart + 2);
     /* Chop off the head */
 
-    while (1) {
-        QString line = responseStream.readLine();
+    foreach (const QString& line, response.split("\r\n")) {
         int sepPos = -1;
-        if (line.isNull()) {
-            break;
-        }
         sepPos = line.indexOf(": ");
         if (sepPos == -1) {
             continue;
@@ -103,7 +98,6 @@
 QDateTime Downloader::getLastModifiedHeader(const QString &resource) {
     int ret = -1;
     QByteArray response;
-    QTextStream responseStream(&response);
     QLocale cLocale = QLocale::c();
     QMap<QString, QString> headers;
     QString headRequest =

http://wald.intevation.org/projects/trustbridge/