Based on a patch by Richard Pospesel.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47035 Signed-off-by: Zebediah Figura z.figura12@gmail.com --- tools/widl/typetree.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c index a7fd561db8..faa582034f 100644 --- a/tools/widl/typetree.c +++ b/tools/widl/typetree.c @@ -265,25 +265,27 @@ type_t *type_new_void(void)
type_t *type_new_enum(const char *name, struct namespace *namespace, int defined, var_list_t *enums) { - type_t *tag_type = name ? find_type(name, namespace, tsENUM) : NULL; - type_t *t = make_type(TYPE_ENUM); - t->name = name; - t->namespace = namespace; - - if (tag_type && tag_type->details.enumeration) - t->details.enumeration = tag_type->details.enumeration; - else if (defined) + type_t *t = NULL; + + if (name) + t = find_type(name, namespace,tsENUM); + + if (!t) + { + t = make_type(TYPE_ENUM); + t->name = name; + t->namespace = namespace; + if (name) + reg_type(t, name, namespace, tsENUM); + } + + if (!t->defined && defined) { t->details.enumeration = xmalloc(sizeof(*t->details.enumeration)); t->details.enumeration->enums = enums; t->defined = TRUE; }
- if (name) - { - if (defined) - reg_type(t, name, namespace, tsENUM); - } return t; }