summaryrefslogtreecommitdiff
path: root/src/core/resource/ResourceManager.cpp
diff options
context:
space:
mode:
authorBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-01-30 14:17:14 +0100
committerBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-01-30 14:17:14 +0100
commit0ba26c258b9c834894de34e7e14a9fdc774988a5 (patch)
treea950b688eca9c347572b6ba691a63d6805264e9f /src/core/resource/ResourceManager.cpp
parent00dcccce979243fa9721e5be27eedc136ad439e5 (diff)
cycle detection for imports as well.
Diffstat (limited to 'src/core/resource/ResourceManager.cpp')
-rw-r--r--src/core/resource/ResourceManager.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/core/resource/ResourceManager.cpp b/src/core/resource/ResourceManager.cpp
index 48d12b3..56c9583 100644
--- a/src/core/resource/ResourceManager.cpp
+++ b/src/core/resource/ResourceManager.cpp
@@ -118,21 +118,18 @@ NodeVector<Node> ResourceManager::parse(
newResource = true;
sourceId = allocateSourceId(resource);
}
+ // check for cycles.
+ GuardedSetInsertion<SourceId> cycleDetection{currentlyParsing, sourceId};
+ if (!cycleDetection.isSuccess()) {
+ throw LoggableException{std::string("Detected cyclic parse of ") +
+ resource.getLocation()};
+ }
if (!newResource && mode == ParseMode::IMPORT) {
// if a already imported resource should be imported we just use the
// cached node.
parsedNodes.push_back(getNode(ctx.getManager(), sourceId));
} else {
- // check for cycles.
- GuardedSetInsertion<SourceId> cycleDetection{currentlyParsing,
- sourceId};
- if (!cycleDetection.isSuccess()) {
- throw LoggableException{
- std::string("Detected cyclic inclusion of ") +
- resource.getLocation()};
- }
-
// We can now try to parse the given file
// Set the current source id in the logger instance. Note that this