From 3ceb686cd7587b3d148b029c39f2ade3f7f97497 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 7 Jun 2001 17:51:07 +0000 Subject: [PATCH] fix LightTransition --- dtool/src/cppparser/cppScope.cxx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/dtool/src/cppparser/cppScope.cxx b/dtool/src/cppparser/cppScope.cxx index 82dd7d65ff..e42b6b9f6b 100644 --- a/dtool/src/cppparser/cppScope.cxx +++ b/dtool/src/cppparser/cppScope.cxx @@ -205,7 +205,21 @@ define_extension_type(CPPExtensionType *type) { } if (type->is_template()) { - _templates.insert(Templates::value_type(name, type)); + pair result = + _templates.insert(Templates::value_type(name, type)); + + if (!result.second) { + // The template was not inserted because we already had a + // template definition with the given name. If the previous + // definition was incomplete, replace it. + CPPDeclaration *old_templ = (*result.first).second; + CPPType *old_templ_type = old_templ->as_type(); + if (old_templ_type == NULL || old_templ_type->is_incomplete()) { + // The previous template definition was incomplete, maybe a + // forward reference; replace it with the good one. + (*result.first).second = type; + } + } } }