From 0ba26c258b9c834894de34e7e14a9fdc774988a5 Mon Sep 17 00:00:00 2001 From: Benjamin Paassen Date: Fri, 30 Jan 2015 14:17:14 +0100 Subject: cycle detection for imports as well. --- src/core/resource/ResourceManager.cpp | 15 ++++++--------- 1 file 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 ResourceManager::parse( newResource = true; sourceId = allocateSourceId(resource); } + // check for cycles. + GuardedSetInsertion 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 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 -- cgit v1.2.3