forked from qt-creator/qt-creator
Use QFileInfo::exists(...) which is faster that QFileInfo(..).exists
Change-Id: I0d2e61d84c74e60ef4f54074a4ca00f2d0835562 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
committed by
Laurent Montel
parent
f976dc96fd
commit
5d27bc747b
@@ -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"))) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -124,7 +124,7 @@ public:
|
||||
fileName.prepend(QLatin1Char('/'));
|
||||
fileName.prepend(_doc->path());
|
||||
}
|
||||
if (!QFileInfo(fileName).exists())
|
||||
if (!QFileInfo::exists(fileName))
|
||||
setMessage(WarnFileOrDirectoryDoesNotExist);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user