From c956f7307362d8ea2f0c2658b5954264fbf2bc05 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Sun, 7 Aug 2011 14:01:53 -0300 Subject: AbstractMetaClasses now hold the instantiation types for the templates they implement. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AbstractMetaClasses that are typedefs for template class instantiations use to keep the template from where they derive, but didn't keep the values used for the derivation. Now this is fixed, and with an unit test. Reviewed by Luciano Wolf Reviewed by Renato Araújo --- abstractmetalang.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'abstractmetalang.cpp') diff --git a/abstractmetalang.cpp b/abstractmetalang.cpp index 106aed1a0..5c1641c42 100644 --- a/abstractmetalang.cpp +++ b/abstractmetalang.cpp @@ -1065,6 +1065,10 @@ AbstractMetaClass::~AbstractMetaClass() qDeleteAll(m_fields); qDeleteAll(m_enums); qDeleteAll(m_orphanInterfaces); + if (hasTemplateBaseClassInstantiations()) { + foreach (AbstractMetaType* inst, templateBaseClassInstantiations()) + delete inst; + } } /******************************************************************************* @@ -1544,7 +1548,29 @@ QPropertySpec *AbstractMetaClass::propertySpecForReset(const QString &name) cons return 0; } +typedef QHash AbstractMetaClassBaseTemplateInstantiationsMap; +Q_GLOBAL_STATIC(AbstractMetaClassBaseTemplateInstantiationsMap, metaClassBaseTemplateInstantiations); + +bool AbstractMetaClass::hasTemplateBaseClassInstantiations() const +{ + if (!templateBaseClass()) + return false; + return metaClassBaseTemplateInstantiations()->contains(this); +} +AbstractMetaTypeList AbstractMetaClass::templateBaseClassInstantiations() const +{ + if (!templateBaseClass()) + return AbstractMetaTypeList(); + return metaClassBaseTemplateInstantiations()->value(this); +} + +void AbstractMetaClass::setTemplateBaseClassInstantiations(AbstractMetaTypeList& instantiations) +{ + if (!templateBaseClass()) + return; + metaClassBaseTemplateInstantiations()->insert(this, instantiations); +} static bool functions_contains(const AbstractMetaFunctionList &l, const AbstractMetaFunction *func) { -- cgit v1.2.3