diff options
author | David Faure <faure@kde.org> | 2012-02-17 14:16:55 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-17 16:42:28 +0100 |
commit | e5bcb4844d71b833d62aedcca3829f44b505dbb0 (patch) | |
tree | 466bd8d79fb1e12120540f00b72758a9361caf65 | |
parent | aee4cbf22a5942c7bd4b9545a8fcb7cf2930e0ee (diff) |
No need to stat with QFile::exists before QFile::open, for reading.
Change-Id: I14ca7f8a377bca39004defc96d69d62c151181f5
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: Jeremy Katz <jeremy.katz@nokia.com>
-rw-r--r-- | src/corelib/io/qstandardpaths_unix.cpp | 2 | ||||
-rw-r--r-- | src/plugins/bearer/connman/qconnmanengine.cpp | 4 | ||||
-rw-r--r-- | src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp | 4 | ||||
-rw-r--r-- | src/widgets/styles/qgtkstyle_p.cpp | 2 |
4 files changed, 6 insertions, 6 deletions
diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp index 6057c26e0d..62c846738e 100644 --- a/src/corelib/io/qstandardpaths_unix.cpp +++ b/src/corelib/io/qstandardpaths_unix.cpp @@ -137,7 +137,7 @@ QString QStandardPaths::writableLocation(StandardLocation type) if (xdgConfigHome.isEmpty()) xdgConfigHome = QDir::homePath() + QLatin1String("/.config"); QFile file(xdgConfigHome + QLatin1String("/user-dirs.dirs")); - if (file.exists() && file.open(QIODevice::ReadOnly)) { + if (file.open(QIODevice::ReadOnly)) { QHash<QString, QString> lines; QTextStream stream(&file); // Only look for lines like: XDG_DESKTOP_DIR="$HOME/Desktop" diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp index 1a874a92b7..0e54668394 100644 --- a/src/plugins/bearer/connman/qconnmanengine.cpp +++ b/src/plugins/bearer/connman/qconnmanengine.cpp @@ -255,7 +255,7 @@ quint64 QConnmanEngine::bytesWritten(const QString &id) quint64 result = 0; QString devFile = getInterfaceFromId(id); QFile tx("/sys/class/net/"+devFile+"/statistics/tx_bytes"); - if(tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) { + if (tx.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&tx); in >> result; tx.close(); @@ -270,7 +270,7 @@ quint64 QConnmanEngine::bytesReceived(const QString &id) quint64 result = 0; QString devFile = getInterfaceFromId(id); QFile rx("/sys/class/net/"+devFile+"/statistics/rx_bytes"); - if(rx.exists() && rx.open(QIODevice::ReadOnly | QIODevice::Text)) { + if (rx.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&rx); in >> result; rx.close(); diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp index fd79cff484..a71a241ea6 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp @@ -837,7 +837,7 @@ quint64 QNetworkManagerEngine::bytesWritten(const QString &id) quint64 result = Q_UINT64_C(0); QFile tx(devFile); - if (tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) { + if (tx.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&tx); in >> result; tx.close(); @@ -865,7 +865,7 @@ quint64 QNetworkManagerEngine::bytesReceived(const QString &id) quint64 result = Q_UINT64_C(0); QFile tx(devFile); - if (tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) { + if (tx.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&tx); in >> result; tx.close(); diff --git a/src/widgets/styles/qgtkstyle_p.cpp b/src/widgets/styles/qgtkstyle_p.cpp index 40ad9f2a95..18e120a4eb 100644 --- a/src/widgets/styles/qgtkstyle_p.cpp +++ b/src/widgets/styles/qgtkstyle_p.cpp @@ -661,7 +661,7 @@ QString QGtkStylePrivate::getThemeName() foreach (const QString &rcPath, paths) { if (!rcPath.isEmpty()) { QFile rcFile(rcPath); - if (rcFile.exists() && rcFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + if (rcFile.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&rcFile); while(!in.atEnd()) { QString line = in.readLine(); |