From 621893a1bec2c4d566d06724672a6136e00c6a67 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 25 Jan 2013 09:34:24 +0100 Subject: wixl: improve automatic detection of the key path Also detect multiple elements with keyPath="yes". --- tools/wixl/builder.vala | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/wixl/builder.vala b/tools/wixl/builder.vala index 8b3d994..2cf9ccd 100644 --- a/tools/wixl/builder.vala +++ b/tools/wixl/builder.vala @@ -347,10 +347,19 @@ namespace Wixl { buffer[12], buffer[13], buffer[14], buffer[15]); } + WixKeyElement? component_default_key = null; + int component_children_count; + public override void visit_component (WixComponent comp, VisitState state) throws GLib.Error { var attr = 0; - if (state == VisitState.ENTER) + if (state == VisitState.ENTER) { + component_default_key = null; + component_children_count = 0; return; + } + + if (comp.key == null && component_default_key != null) + comp.key = component_default_key; if (comp.key is WixRegistryValue) attr |= ComponentAttribute.REGISTRY_KEY_PATH; @@ -483,8 +492,14 @@ namespace Wixl { return_if_fail (component != null); - if (component.key == null || parse_yesno (key.KeyPath)) + if (component_children_count++ == 0) + component_default_key = key; + if (parse_yesno (key.KeyPath)) { + component_default_key = null; + if (component.key != null) + throw new Wixl.Error.FAILED ("multiple elements have keyPath='yes'"); component.key = key; + } } enum RegistryValueType { -- cgit