aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Cullmann <cullmann@kde.org>2014-01-21 11:21:09 (GMT)
committerChristoph Cullmann <cullmann@kde.org>2014-01-21 11:21:09 (GMT)
commit162b785e751d56ac125fa568e3c369b0d5f5046b (patch)
tree81eefcdaa60392b2341056c7bada0a48873ec0d2
parent33a4e9e9e740b4c351360841c4357bd81af19b72 (diff)
better recursion guard, like if have in the project plugin
-rw-r--r--src/document/katedocument.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/document/katedocument.cpp b/src/document/katedocument.cpp
index bdfa69e..dcf9e30 100644
--- a/src/document/katedocument.cpp
+++ b/src/document/katedocument.cpp
@@ -2327,15 +2327,19 @@ void KTextEditor::DocumentPrivate::readDirConfig()
return;
/**
- * go up to /
+ * search .kateconfig upwards
+ * with recursion guard
*/
- QString currentDir = QFileInfo(localFilePath()).absolutePath();
- Q_FOREVER {
- //qCDebug(LOG_PART) << "search for config file in path: " << currentDir;
+ QSet<QString> seenDirectories;
+ QDir dir (QFileInfo(localFilePath()).absolutePath());
+ while (!seenDirectories.contains (dir.absolutePath ())) {
+ /**
+ * fill recursion guard
+ */
+ seenDirectories.insert (dir.absolutePath ());
// try to open config file in this dir
- QFile f(currentDir + QLatin1String("/.kateconfig"));
-
+ QFile f(dir.absolutePath () + QLatin1String("/.kateconfig"));
if (f.open(QIODevice::ReadOnly)) {
QTextStream stream(&f);
@@ -2352,14 +2356,11 @@ void KTextEditor::DocumentPrivate::readDirConfig()
break;
}
- QString newDir = QFileInfo(currentDir).absolutePath();
-
- // bail out on looping (for example reached /)
- if (currentDir == newDir) {
+ /**
+ * else: cd up, if possible or abort
+ */
+ if (!dir.cdUp())
break;
- }
-
- currentDir = newDir;
}
}