Skip to content
Snippets Groups Projects
Commit b82475b0 authored by Friedemann Kleint's avatar Friedemann Kleint Committed by hjk
Browse files

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: default avatarhjk <qthjk@ovi.com>
parent 92cc5146
No related branches found
No related tags found
No related merge requests found
...@@ -110,12 +110,13 @@ public: ...@@ -110,12 +110,13 @@ public:
return result; return result;
} }
void resetCache(const QString &dir) void resetCache(const QString &dirIn)
{ {
Q_ASSERT(QDir(dir).isAbsolute()); const QDir qDir = QDir(dirIn);
Q_ASSERT(!dir.endsWith(QLatin1Char('/'))); QTC_ASSERT(qDir.exists(), qWarning("%s: '%s' does not exist.",
Q_ASSERT(QDir::fromNativeSeparators(dir) == dir); Q_FUNC_INFO, qPrintable(dirIn));
return; )
const QString dir = qDir.absolutePath();
const QString dirSlash = dir + QLatin1Char('/'); const QString dirSlash = dir + QLatin1Char('/');
foreach (const QString &key, m_cachedMatches.keys()) { foreach (const QString &key, m_cachedMatches.keys()) {
if (key == dir || key.startsWith(dirSlash)) if (key == dir || key.startsWith(dirSlash))
...@@ -123,13 +124,16 @@ public: ...@@ -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()); const QDir qDir(dirIn);
Q_ASSERT(!dir.endsWith(QLatin1Char('/'))); QTC_ASSERT(qDir.exists(), qWarning("%s: '%s' does not exist.",
Q_ASSERT(QDir::fromNativeSeparators(dir) == dir); Q_FUNC_INFO, qPrintable(dirIn));
Q_ASSERT(dir.startsWith(topLevel)); 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); VcsInfo *newInfo = new VcsInfo(vc, topLevel);
bool createdNewInfo(true); bool createdNewInfo(true);
// Do we have a matching VcsInfo already? // Do we have a matching VcsInfo already?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment