From f2f882a9f67c1bb0ce3571b053eb7d0749b2d3e9 Mon Sep 17 00:00:00 2001 From: Alessandro Portale <alessandro.portale@nokia.com> Date: Mon, 23 Aug 2010 20:22:21 +0200 Subject: [PATCH] Checking for isNull() in the head of the loop Less readable, but perhaps more robust. --- .../wizards/qmlstandaloneapp.cpp | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.cpp b/src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.cpp index cb9288148dc..f9822ab7c20 100644 --- a/src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.cpp +++ b/src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.cpp @@ -294,8 +294,7 @@ QByteArray QmlStandaloneApp::generateMainCpp(const QString *errorMessage) const QTextStream out(&mainCppContent, QIODevice::WriteOnly); QString line; - do { - line = in.readLine(); + while (!(line = in.readLine()).isNull()) { if (line.contains(QLatin1String("// MAINQML"))) { line = insertParameter(line, QLatin1Char('"') + path(MainQmlDeployed) + QLatin1Char('"')); } else if (line.contains(QLatin1String("// ADDIMPORTPATH"))) { @@ -317,7 +316,7 @@ QByteArray QmlStandaloneApp::generateMainCpp(const QString *errorMessage) const if (commentIndex != -1) line.truncate(commentIndex); out << line << endl; - } while (!line.isNull()); + }; return mainCppContent; } @@ -335,19 +334,19 @@ QByteArray QmlStandaloneApp::generateProFile(const QString *errorMessage) const QByteArray proFileContent; QTextStream out(&proFileContent, QIODevice::WriteOnly); - QString line; QString valueOnNextLine; bool uncommentNextLine = false; - do { - line = in.readLine(); - + QString line; + while (!(line = in.readLine()).isNull()) { if (line.contains(QLatin1String("# TARGETUID3"))) { valueOnNextLine = symbianTargetUid(); } else if (line.contains(QLatin1String("# DEPLOYMENTFOLDERS"))) { // Eat lines - do { - line = in.readLine(); - } while (!(line.isNull() || line.contains(QLatin1String("# DEPLOYMENTFOLDERS_END")))); + while (!(line = in.readLine()).isNull() && + !line.contains(QLatin1String("# DEPLOYMENTFOLDERS_END"))) + { } + if (line.isNull()) + break; QStringList folders; out << "folder_01.source = " << path(QmlDirProFileRelative) << endl; out << "folder_01.target = qml" << endl; @@ -391,7 +390,7 @@ QByteArray QmlStandaloneApp::generateProFile(const QString *errorMessage) const continue; } out << line << endl; - } while (!line.isNull()); + }; return proFileContent; } @@ -450,13 +449,13 @@ bool QmlStandaloneApp::addCppPlugins(QmlModule *module) { QFile qmlDirFile(module->qmldir.absoluteFilePath()); if (qmlDirFile.open(QIODevice::ReadOnly)) { - QTextStream ts(&qmlDirFile); + QTextStream in(&qmlDirFile); QString line; - do { - line = ts.readLine().trimmed(); + while (!(line = in.readLine()).isNull()) { + line = line.trimmed(); if (line.startsWith(qmldir_plugin) && !addCppPlugin(line, module)) return false; - } while (!line.isNull()); + }; } return true; } -- GitLab