diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2012-01-12 08:55:57 +0100 |
---|---|---|
committer | hjk <qthjk@ovi.com> | 2012-01-12 11:20:57 +0100 |
commit | b82475b0e99419d403fd15a1b81b9efea17c8ab5 (patch) | |
tree | 9ff62f32299b27eac5463e1760ea9082f1469a82 /src/plugins/coreplugin/vcsmanager.cpp | |
parent | 92cc5146d3e92573574d0921f3ca01059d4b34ca (diff) | |
download | qt-creator-b82475b0e99419d403fd15a1b81b9efea17c8ab5.tar.gz |
Change asserts() to soft-asserts in Vcs-Cache.
- Prevent crash when creating a project.
- Use QDir to normalize the path (as it is constrcuted in
the assert anyway).
- Print proper warnings.
Change-Id: Ib6fa3c564aff20b73d6efc08ca3a13688fd97dce
Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'src/plugins/coreplugin/vcsmanager.cpp')
-rw-r--r-- | src/plugins/coreplugin/vcsmanager.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/plugins/coreplugin/vcsmanager.cpp b/src/plugins/coreplugin/vcsmanager.cpp index cc68c0d259..baea7ffe9a 100644 --- a/src/plugins/coreplugin/vcsmanager.cpp +++ b/src/plugins/coreplugin/vcsmanager.cpp @@ -110,12 +110,13 @@ public: return result; } - void resetCache(const QString &dir) + void resetCache(const QString &dirIn) { - Q_ASSERT(QDir(dir).isAbsolute()); - Q_ASSERT(!dir.endsWith(QLatin1Char('/'))); - Q_ASSERT(QDir::fromNativeSeparators(dir) == 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(); const QString dirSlash = dir + QLatin1Char('/'); foreach (const QString &key, m_cachedMatches.keys()) { if (key == dir || key.startsWith(dirSlash)) @@ -123,13 +124,16 @@ public: } } - void cache(IVersionControl *vc, const QString topLevel, const QString dir) + void cache(IVersionControl *vc, const QString &topLevel, const QString &dirIn) { - Q_ASSERT(QDir(dir).isAbsolute()); - Q_ASSERT(!dir.endsWith(QLatin1Char('/'))); - Q_ASSERT(QDir::fromNativeSeparators(dir) == dir); - Q_ASSERT(dir.startsWith(topLevel)); - + 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; ) VcsInfo *newInfo = new VcsInfo(vc, topLevel); bool createdNewInfo(true); // Do we have a matching VcsInfo already? |