diff options
author | Tobias Hunger <tobias.hunger@nokia.com> | 2012-01-12 14:27:40 +0100 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@nokia.com> | 2012-01-13 14:16:45 +0100 |
commit | 7d3ba0e9b485674757e60d938a7a0118bca6f973 (patch) | |
tree | 51373a329d8b5c4f2cfdcd609025d4b55daa2965 /src/plugins/coreplugin/vcsmanager.cpp | |
parent | 61082af6af37d34bbb210d5f28e47df2cf1714d0 (diff) | |
download | qt-creator-7d3ba0e9b485674757e60d938a7a0118bca6f973.tar.gz |
VCSmanager: Fix QTC_ASSERTs
These tests are needed to make sure no broken data ends up in the cache,
causing inconsistencies in the cache. The asserts did a good job there,
catching a couple of issue, so I would like to keep them the way they are.
QDir is not needed at all as the data _should_ be perfectly fine already
anyway and should not be used if the asserts are not evaluated.
Change-Id: Icf113f8b02b6c7c7ba7498386b8465b2644daae8
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
Diffstat (limited to 'src/plugins/coreplugin/vcsmanager.cpp')
-rw-r--r-- | src/plugins/coreplugin/vcsmanager.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/plugins/coreplugin/vcsmanager.cpp b/src/plugins/coreplugin/vcsmanager.cpp index baea7ffe9a..402b55eba1 100644 --- a/src/plugins/coreplugin/vcsmanager.cpp +++ b/src/plugins/coreplugin/vcsmanager.cpp @@ -110,13 +110,12 @@ public: return result; } - void resetCache(const QString &dirIn) + void resetCache(const QString &dir) { - const QDir qDir = QDir(dirIn); - QTC_ASSERT(qDir.exists(), qWarning("%s: '%s' does not exist.", - Q_FUNC_INFO, qPrintable(dirIn)); - return; ) - const QString dir = qDir.absolutePath(); + QTC_ASSERT(QDir(dir).isAbsolute(), return); + QTC_ASSERT(!dir.endsWith(QLatin1Char('/')), return); + QTC_ASSERT(QDir::fromNativeSeparators(dir) == dir, return); + const QString dirSlash = dir + QLatin1Char('/'); foreach (const QString &key, m_cachedMatches.keys()) { if (key == dir || key.startsWith(dirSlash)) @@ -124,16 +123,13 @@ public: } } - void cache(IVersionControl *vc, const QString &topLevel, const QString &dirIn) + void cache(IVersionControl *vc, const QString &topLevel, const QString &dir) { - const QDir qDir(dirIn); - QTC_ASSERT(qDir.exists(), qWarning("%s: '%s' does not exist.", - Q_FUNC_INFO, qPrintable(dirIn)); - return; ) - const QString dir = qDir.absolutePath(); - QTC_ASSERT(dir.startsWith(topLevel), qWarning("%s: '%s' does not start with '%s'.", - Q_FUNC_INFO, qPrintable(dir), qPrintable(topLevel)); - return; ) + QTC_ASSERT(QDir(dir).isAbsolute(), return); + QTC_ASSERT(!dir.endsWith(QLatin1Char('/')), return); + QTC_ASSERT(QDir::fromNativeSeparators(dir) == dir, return); + QTC_ASSERT(dir.startsWith(topLevel + QLatin1Char('/')) || topLevel == dir, return); + VcsInfo *newInfo = new VcsInfo(vc, topLevel); bool createdNewInfo(true); // Do we have a matching VcsInfo already? |