aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMontel Laurent <laurent.montel@kdab.com>2017-04-13 16:26:38 +0200
committerLaurent Montel <laurent.montel@kdab.com>2017-04-14 13:18:28 +0000
commit5d27bc747b622355f5e434824a7d7ae5772683ab (patch)
treee7e9e86eae39a89244b8422db376dfa529cc6f98
parentf976dc96fd9267bd51bde31ebeec8bdeb21d3fc8 (diff)
Use QFileInfo::exists(...) which is faster that QFileInfo(..).exists
Change-Id: I0d2e61d84c74e60ef4f54074a4ca00f2d0835562 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp6
-rw-r--r--share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.cpp4
-rw-r--r--share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate_56.cpp4
-rw-r--r--src/libs/qmleditorwidgets/contextpanewidgetimage.cpp4
-rw-r--r--src/libs/qmljs/qmljscheck.cpp2
-rw-r--r--src/libs/utils/consoleprocess_unix.cpp3
-rw-r--r--src/libs/utils/pathchooser.cpp2
-rw-r--r--src/plugins/clearcase/clearcaseplugin.cpp4
-rw-r--r--src/plugins/clearcase/clearcasesync.cpp2
-rw-r--r--src/plugins/coreplugin/editormanager/editorview.cpp2
-rw-r--r--src/plugins/git/gitclient.cpp2
-rw-r--r--src/plugins/projectexplorer/devicesupport/devicemanager.cpp2
-rw-r--r--src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp2
-rw-r--r--tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp2
14 files changed, 21 insertions, 20 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp
index 8cd156345d..cea0946105 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp
@@ -420,7 +420,7 @@ void ObjectNodeInstance::setPropertyVariant(const PropertyName &name, const QVar
if (oldValue.type() == QVariant::Url) {
QUrl url = oldValue.toUrl();
QString path = url.toLocalFile();
- if (QFileInfo(path).exists() && nodeInstanceServer() && !path.isEmpty())
+ if (QFileInfo::exists(path) && nodeInstanceServer() && !path.isEmpty())
nodeInstanceServer()->removeFilePropertyFromFileSystemWatcher(object(), name, path);
}
@@ -437,7 +437,7 @@ void ObjectNodeInstance::setPropertyVariant(const PropertyName &name, const QVar
if (newValue.type() == QVariant::Url) {
QUrl url = newValue.toUrl();
QString path = url.toLocalFile();
- if (QFileInfo(path).exists() && nodeInstanceServer() && !path.isEmpty())
+ if (QFileInfo::exists(path) && nodeInstanceServer() && !path.isEmpty())
nodeInstanceServer()->addFilePropertyToFileSystemWatcher(object(), name, path);
}
}
@@ -678,7 +678,7 @@ static inline QString fixComponentPathForIncompatibleQt(const QString &component
const QString relativeImportPath = componentPath.right(componentPath.length() - index);
QString fixedComponentPath = QLibraryInfo::location(QLibraryInfo::ImportsPath) + relativeImportPath;
fixedComponentPath.replace(QLatin1Char('\\'), QLatin1Char('/'));
- if (QFileInfo(fixedComponentPath).exists())
+ if (QFileInfo::exists(fixedComponentPath))
return fixedComponentPath;
QString fixedPath = QFileInfo(fixedComponentPath).path();
if (fixedPath.endsWith(QLatin1String(".1.0"))) {
diff --git a/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.cpp b/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.cpp
index b55374220d..3243db8fc0 100644
--- a/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.cpp
@@ -389,7 +389,7 @@ QVariant fixResourcePaths(const QVariant &value)
if (qrcDefintion.count() == 2) {
QString fixedPath = path;
fixedPath.replace(QLatin1String("qrc:") + qrcDefintion.first(), qrcDefintion.last() + QLatin1Char('/'));
- if (QFileInfo(fixedPath).exists()) {
+ if (QFileInfo::exists(fixedPath)) {
fixedPath.replace(QLatin1String("//"), QLatin1String("/"));
fixedPath.replace(QLatin1Char('\\'), QLatin1Char('/'));
return QUrl::fromLocalFile(fixedPath);
@@ -410,7 +410,7 @@ QVariant fixResourcePaths(const QVariant &value)
if (qrcDefintion.count() == 2) {
QString fixedPath = str;
fixedPath.replace(QLatin1String("qrc:") + qrcDefintion.first(), qrcDefintion.last() + QLatin1Char('/'));
- if (QFileInfo(fixedPath).exists()) {
+ if (QFileInfo::exists(fixedPath)) {
fixedPath.replace(QLatin1String("//"), QLatin1String("/"));
fixedPath.replace(QLatin1Char('\\'), QLatin1Char('/'));
return fixedPath;
diff --git a/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate_56.cpp b/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate_56.cpp
index 15d2aa5daf..cbc4e54fb1 100644
--- a/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate_56.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate_56.cpp
@@ -102,7 +102,7 @@ QVariant fixResourcePaths(const QVariant &value)
if (qrcDefintion.count() == 2) {
QString fixedPath = path;
fixedPath.replace(QLatin1String("qrc:") + qrcDefintion.first(), qrcDefintion.last() + QLatin1Char('/'));
- if (QFileInfo(fixedPath).exists()) {
+ if (QFileInfo::exists(fixedPath)) {
fixedPath.replace(QLatin1String("//"), QLatin1String("/"));
fixedPath.replace(QLatin1Char('\\'), QLatin1Char('/'));
return QUrl::fromLocalFile(fixedPath);
@@ -123,7 +123,7 @@ QVariant fixResourcePaths(const QVariant &value)
if (qrcDefintion.count() == 2) {
QString fixedPath = str;
fixedPath.replace(QLatin1String("qrc:") + qrcDefintion.first(), qrcDefintion.last() + QLatin1Char('/'));
- if (QFileInfo(fixedPath).exists()) {
+ if (QFileInfo::exists(fixedPath)) {
fixedPath.replace(QLatin1String("//"), QLatin1String("/"));
fixedPath.replace(QLatin1Char('\\'), QLatin1Char('/'));
return QUrl::fromLocalFile(fixedPath);
diff --git a/src/libs/qmleditorwidgets/contextpanewidgetimage.cpp b/src/libs/qmleditorwidgets/contextpanewidgetimage.cpp
index 4c4db4c116..188e19ae7d 100644
--- a/src/libs/qmleditorwidgets/contextpanewidgetimage.cpp
+++ b/src/libs/qmleditorwidgets/contextpanewidgetimage.cpp
@@ -482,7 +482,7 @@ void ContextPaneWidgetImage::setPixmap(const QString &fileName)
if (m_borderImage) {
QString localFileName(fileName);
- if (QFile(fileName).exists()) {
+ if (QFileInfo::exists(fileName)) {
if (fileName.endsWith(QLatin1String("sci"))) {
QString pixmapFileName;
int left = 0;
@@ -527,7 +527,7 @@ void ContextPaneWidgetImage::setPixmap(const QString &fileName)
}
uiBorderImage->label->setPixmap(pix);
} else {
- if (QFile(fileName).exists()) {
+ if (QFileInfo::exists(fileName)) {
QPixmap source(fileName);
previewDialog()->setPixmap(source, 1);
ui->sizeLabel->setText(QString::number(source.width()) + QLatin1Char('x') + QString::number(source.height()));
diff --git a/src/libs/qmljs/qmljscheck.cpp b/src/libs/qmljs/qmljscheck.cpp
index 803b47df77..9d3cb2a142 100644
--- a/src/libs/qmljs/qmljscheck.cpp
+++ b/src/libs/qmljs/qmljscheck.cpp
@@ -124,7 +124,7 @@ public:
fileName.prepend(QLatin1Char('/'));
fileName.prepend(_doc->path());
}
- if (!QFileInfo(fileName).exists())
+ if (!QFileInfo::exists(fileName))
setMessage(WarnFileOrDirectoryDoesNotExist);
}
}
diff --git a/src/libs/utils/consoleprocess_unix.cpp b/src/libs/utils/consoleprocess_unix.cpp
index bd30758933..29e3d1845c 100644
--- a/src/libs/utils/consoleprocess_unix.cpp
+++ b/src/libs/utils/consoleprocess_unix.cpp
@@ -31,6 +31,7 @@
#include <utils/qtcassert.h>
#include <QCoreApplication>
+#include <QFileInfo>
#include <QSettings>
#include <QTimer>
@@ -359,7 +360,7 @@ QString ConsoleProcess::defaultTerminalEmulator()
{
if (HostOsInfo::isMacHost()) {
QString termCmd = QCoreApplication::applicationDirPath() + QLatin1String("/../Resources/scripts/openTerminal.command");
- if (QFile(termCmd).exists())
+ if (QFileInfo::exists(termCmd))
return termCmd.replace(QLatin1Char(' '), QLatin1String("\\ "));
return QLatin1String("/usr/X11/bin/xterm");
}
diff --git a/src/libs/utils/pathchooser.cpp b/src/libs/utils/pathchooser.cpp
index bc20f85efc..bb79efe8db 100644
--- a/src/libs/utils/pathchooser.cpp
+++ b/src/libs/utils/pathchooser.cpp
@@ -56,7 +56,7 @@ static QString appBundleExpandedPath(const QString &path)
QFileInfo info(path);
if (info.isDir()) {
QString exePath = path + QLatin1String("/Contents/MacOS/") + info.completeBaseName();
- if (QFileInfo(exePath).exists())
+ if (QFileInfo::exists(exePath))
return exePath;
}
}
diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp
index c5beb51b43..f4ba55d093 100644
--- a/src/plugins/clearcase/clearcaseplugin.cpp
+++ b/src/plugins/clearcase/clearcaseplugin.cpp
@@ -257,7 +257,7 @@ FileStatus::Status ClearCasePlugin::getFileStatus(const QString &fileName) const
const QString absFile =
viewRootDir.absoluteFilePath(
QDir::fromNativeSeparators(buffer.left(atatpos)));
- QTC_CHECK(QFile(absFile).exists());
+ QTC_CHECK(QFileInfo::exists(absFile));
QTC_CHECK(!absFile.isEmpty());
// "cleartool ls" of a derived object looks like this:
@@ -274,7 +274,7 @@ FileStatus::Status ClearCasePlugin::getFileStatus(const QString &fileName) const
else
return FileStatus::CheckedIn;
} else {
- QTC_CHECK(QFile(fileName).exists());
+ QTC_CHECK(QFileInfo::exists(fileName));
QTC_CHECK(!fileName.isEmpty());
return FileStatus::NotManaged;
}
diff --git a/src/plugins/clearcase/clearcasesync.cpp b/src/plugins/clearcase/clearcasesync.cpp
index 8f8262ee7c..2a9c16dfd7 100644
--- a/src/plugins/clearcase/clearcasesync.cpp
+++ b/src/plugins/clearcase/clearcasesync.cpp
@@ -92,7 +92,7 @@ void ClearCaseSync::processCleartoolLsLine(const QDir &viewRootDir, const QStrin
const QString absFile =
viewRootDir.absoluteFilePath(
QDir::fromNativeSeparators(buffer.left(atatpos)));
- QTC_CHECK(QFile(absFile).exists());
+ QTC_CHECK(QFileInfo::exists(absFile));
QTC_CHECK(!absFile.isEmpty());
QString ccState;
diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp
index 99556068e1..b46c71f772 100644
--- a/src/plugins/coreplugin/editormanager/editorview.cpp
+++ b/src/plugins/coreplugin/editormanager/editorview.cpp
@@ -547,7 +547,7 @@ void EditorView::updateCurrentPositionInNavigationHistory()
namespace {
static inline bool fileNameWasRemoved(const QString &fileName)
{
- return !fileName.isEmpty() && !QFileInfo(fileName).exists();
+ return !fileName.isEmpty() && !QFileInfo::exists(fileName);
}
} // End of anonymous namespace
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index 7fb0790cbf..1e730091ac 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -2187,7 +2187,7 @@ bool GitClient::tryLauchingGitK(const QProcessEnvironment &env,
if (HostOsInfo::isWindowsHost()) {
// If git/bin is in path, use 'wish' shell to run. Otherwise (git/cmd), directly run gitk
QString wish = gitBinDirectory + "/wish";
- if (QFileInfo(wish + ".exe").exists()) {
+ if (QFileInfo::exists(wish + ".exe")) {
arguments << binary;
binary = wish;
}
diff --git a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp
index b1792e6fd5..39b17a6444 100644
--- a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp
+++ b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp
@@ -357,7 +357,7 @@ DeviceManager::DeviceManager(bool isInstance) : d(new DeviceManagerPrivate)
m_instance = this;
d->hostKeyDatabase = QSsh::SshHostKeyDatabasePtr::create();
const QString keyFilePath = hostKeysFilePath();
- if (QFileInfo(keyFilePath).exists()) {
+ if (QFileInfo::exists(keyFilePath)) {
QString error;
if (!d->hostKeyDatabase->load(keyFilePath, &error))
Core::MessageManager::write(error);
diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp
index 3c2a247e9a..9b97254f60 100644
--- a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp
+++ b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp
@@ -327,7 +327,7 @@ void JsonWizard::openFiles(const JsonWizard::GeneratorFiles &files)
bool openedSomething = false;
foreach (const JsonWizard::GeneratorFile &f, files) {
const Core::GeneratedFile &file = f.file;
- if (!QFileInfo(file.path()).exists()) {
+ if (!QFileInfo::exists(file.path())) {
errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard",
"\"%1\" does not exist in the file system.")
.arg(QDir::toNativeSeparators(file.path()));
diff --git a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp
index 177df3a4f3..25fd1008d3 100644
--- a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp
+++ b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp
@@ -205,7 +205,7 @@ void tst_TestCore::initTestCase()
#endif
qDebug() << pluginPath;
- Q_ASSERT(QFileInfo(pluginPath).exists());
+ Q_ASSERT(QFileInfo::exists(pluginPath));
MetaInfo::setPluginPaths(QStringList() << pluginPath);
QFileInfo builtins(resourcePath() + "/qml-type-descriptions/builtins.qmltypes");