From ecf3397df83108cd8d51e9d6a2ea9b1462098fa4 Mon Sep 17 00:00:00 2001 From: Chen Gong Date: Fri, 15 Sep 2017 19:35:56 +0800 Subject: [PATCH] fix(config_compiler): linking failure on blocking root node of a dependency resource --- src/rime/config/config_compiler.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/rime/config/config_compiler.cc b/src/rime/config/config_compiler.cc index d3ea0c2d09..6e8b23091c 100644 --- a/src/rime/config/config_compiler.cc +++ b/src/rime/config/config_compiler.cc @@ -468,6 +468,11 @@ static an ResolveReference(ConfigCompiler* compiler, if (!resource) { DLOG(INFO) << "resource not loaded, compiling: " << reference.resource_id; resource = compiler->Compile(reference.resource_id); + // dependency doesn't require full resolution, this allows non conflicting + // mutual references between config files. + // this call is made even if resource is not loaded because plugins can + // edit the empty config data, adding new dependencies. + ResolveBlockingDependencies(compiler, reference.resource_id + ":"); if (!resource->loaded) { if (reference.optional) { LOG(INFO) << "optional resource not loaded: " << reference.resource_id; @@ -557,10 +562,11 @@ bool ConfigCompiler::Link(an target) { bool ConfigCompiler::ResolveDependencies(const string& path) { DLOG(INFO) << "ResolveDependencies(" << path << ")"; - if (!graph_->deps.count(path)) { + auto found = graph_->deps.find(path); + if (found == graph_->deps.end()) { return true; } - auto& deps = graph_->deps[path]; + auto& deps = found->second; for (auto iter = deps.begin(); iter != deps.end(); ) { if (!(*iter)->Resolve(this)) { LOG(ERROR) << "unresolved dependency: " << **iter;