VcsManager: Use nullptr and member initialization

Change-Id: I7a04d609f62d1a221eb2b814a67b2dd816d90e6c
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Tobias Hunger
2017-06-15 13:42:59 +02:00
parent 232fb7a425
commit abdc6790ee

View File

@@ -77,9 +77,6 @@ public:
QString topLevel; QString topLevel;
}; };
VcsManagerPrivate() : m_unconfiguredVcs(0), m_cachedAdditionalToolsPathsDirty(true)
{ }
~VcsManagerPrivate() ~VcsManagerPrivate()
{ {
qDeleteAll(m_vcsInfoList); qDeleteAll(m_vcsInfoList);
@@ -87,26 +84,26 @@ public:
VcsInfo *findInCache(const QString &dir) VcsInfo *findInCache(const QString &dir)
{ {
QTC_ASSERT(QDir(dir).isAbsolute(), return 0); QTC_ASSERT(QDir(dir).isAbsolute(), return nullptr);
QTC_ASSERT(!dir.endsWith(QLatin1Char('/')), return 0); QTC_ASSERT(!dir.endsWith(QLatin1Char('/')), return nullptr);
QTC_ASSERT(QDir::fromNativeSeparators(dir) == dir, return 0); QTC_ASSERT(QDir::fromNativeSeparators(dir) == dir, return nullptr);
const QMap<QString, VcsInfo *>::const_iterator it = m_cachedMatches.constFind(dir); const QMap<QString, VcsInfo *>::const_iterator it = m_cachedMatches.constFind(dir);
if (it != m_cachedMatches.constEnd()) if (it != m_cachedMatches.constEnd())
return it.value(); return it.value();
return 0; return nullptr;
} }
VcsInfo *findUpInCache(const QString &directory) VcsInfo *findUpInCache(const QString &directory)
{ {
VcsInfo *result = 0; VcsInfo *result = nullptr;
const QChar slash = QLatin1Char('/'); const QChar slash = QLatin1Char('/');
// Split the path, trying to find the matching repository. We start from the reverse // Split the path, trying to find the matching repository. We start from the reverse
// in order to detected nested repositories correctly (say, a git checkout under SVN). // in order to detected nested repositories correctly (say, a git checkout under SVN).
for (int pos = directory.size() - 1; pos >= 0; pos = directory.lastIndexOf(slash, pos) - 1) { for (int pos = directory.size() - 1; pos >= 0; pos = directory.lastIndexOf(slash, pos) - 1) {
const QString directoryPart = directory.left(pos); const QString directoryPart = directory.left(pos);
result = findInCache(directoryPart); result = findInCache(directoryPart);
if (result != 0) if (result)
break; break;
} }
return result; return result;
@@ -171,14 +168,14 @@ public:
QMap<QString, VcsInfo *> m_cachedMatches; QMap<QString, VcsInfo *> m_cachedMatches;
QList<VcsInfo *> m_vcsInfoList; QList<VcsInfo *> m_vcsInfoList;
IVersionControl *m_unconfiguredVcs; IVersionControl *m_unconfiguredVcs = nullptr;
QStringList m_cachedAdditionalToolsPaths; QStringList m_cachedAdditionalToolsPaths;
bool m_cachedAdditionalToolsPathsDirty; bool m_cachedAdditionalToolsPathsDirty = true;
}; };
static VcsManagerPrivate *d = 0; static VcsManagerPrivate *d = nullptr;
static VcsManager *m_instance = 0; static VcsManager *m_instance = nullptr;
VcsManager::VcsManager(QObject *parent) : VcsManager::VcsManager(QObject *parent) :
QObject(parent) QObject(parent)
@@ -191,7 +188,7 @@ VcsManager::VcsManager(QObject *parent) :
VcsManager::~VcsManager() VcsManager::~VcsManager()
{ {
m_instance = 0; m_instance = nullptr;
delete d; delete d;
} }
@@ -249,7 +246,7 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input
if (inputDirectory.isEmpty()) { if (inputDirectory.isEmpty()) {
if (topLevelDirectory) if (topLevelDirectory)
topLevelDirectory->clear(); topLevelDirectory->clear();
return 0; return nullptr;
} }
// Make sure we an absolute path: // Make sure we an absolute path:
@@ -282,12 +279,12 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input
}); });
if (allThatCanManage.isEmpty()) { if (allThatCanManage.isEmpty()) {
d->cache(0, QString(), directory); // register that nothing was found! d->cache(nullptr, QString(), directory); // register that nothing was found!
// report result; // report result;
if (topLevelDirectory) if (topLevelDirectory)
topLevelDirectory->clear(); topLevelDirectory->clear();
return 0; return nullptr;
} }
// Register Vcs(s) with the cache // Register Vcs(s) with the cache
@@ -325,11 +322,11 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input
if (isVcsConfigured) { if (isVcsConfigured) {
if (curDocument && d->m_unconfiguredVcs == versionControl) { if (curDocument && d->m_unconfiguredVcs == versionControl) {
curDocument->infoBar()->removeInfo(vcsWarning); curDocument->infoBar()->removeInfo(vcsWarning);
d->m_unconfiguredVcs = 0; d->m_unconfiguredVcs = nullptr;
} }
return versionControl; return versionControl;
} else { } else {
InfoBar *infoBar = curDocument ? curDocument->infoBar() : 0; InfoBar *infoBar = curDocument ? curDocument->infoBar() : nullptr;
if (infoBar && infoBar->canInfoBeAdded(vcsWarning)) { if (infoBar && infoBar->canInfoBeAdded(vcsWarning)) {
InfoBarEntry info(vcsWarning, InfoBarEntry info(vcsWarning,
tr("%1 repository was detected but %1 is not configured.") tr("%1 repository was detected but %1 is not configured.")
@@ -343,7 +340,7 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input
infoBar->addInfo(info); infoBar->addInfo(info);
} }
return 0; return nullptr;
} }
} }
return versionControl; return versionControl;