@@ -210,12 +210,11 @@ AbstractMetaClass *AbstractMetaBuilder::argumentToClass(ArgumentModelItem argume
210210{
211211 AbstractMetaClass *returned = 0 ;
212212 bool ok = false ;
213- AbstractMetaType * type = translateType (argument->type (), &ok);
213+ AbstractMetaType::shared_pointer type = translateType (argument->type (), &ok);
214214 if (ok && type != 0 && type->typeEntry () != 0 && type->typeEntry ()->isComplex ()) {
215215 const TypeEntry *entry = type->typeEntry ();
216216 returned = m_meta_classes.findClass (entry->name ());
217217 }
218- delete type;
219218 return returned;
220219}
221220
@@ -1017,7 +1016,7 @@ AbstractMetaField *AbstractMetaBuilder::traverseField(VariableModelItem field, c
10171016
10181017 bool ok;
10191018 TypeInfo field_type = field->type ();
1020- AbstractMetaType * meta_type = translateType (field_type, &ok);
1019+ AbstractMetaType::shared_pointer meta_type = translateType (field_type, &ok);
10211020
10221021 if (!meta_type || !ok) {
10231022 ReportHandler::warning (QString (" skipping field '%1::%2' with unmatched type '%3'" )
@@ -1464,7 +1463,7 @@ AbstractMetaFunction *AbstractMetaBuilder::traverseFunction(FunctionModelItem fu
14641463 meta_function->setName (m_current_class->name ());
14651464 } else {
14661465 bool ok;
1467- AbstractMetaType * type = 0 ;
1466+ AbstractMetaType::shared_pointer type = 0 ;
14681467
14691468 if (!cast_type.isEmpty ()) {
14701469 TypeInfo info;
@@ -1502,7 +1501,7 @@ AbstractMetaFunction *AbstractMetaBuilder::traverseFunction(FunctionModelItem fu
15021501 ArgumentModelItem arg = arguments.at (i);
15031502
15041503 bool ok;
1505- AbstractMetaType * meta_type = translateType (arg->type (), &ok);
1504+ AbstractMetaType::shared_pointer meta_type = translateType (arg->type (), &ok);
15061505 if (!meta_type || !ok) {
15071506 ReportHandler::warning (QString (" skipping function '%1::%2', "
15081507 " unmatched parameter type '%3'" )
@@ -1571,7 +1570,7 @@ AbstractMetaFunction *AbstractMetaBuilder::traverseFunction(FunctionModelItem fu
15711570}
15721571
15731572
1574- AbstractMetaType * AbstractMetaBuilder::translateType (const TypeInfo &_typei, bool *ok, bool resolveType, bool resolveScope)
1573+ AbstractMetaType::shared_pointer AbstractMetaBuilder::translateType (const TypeInfo &_typei, bool *ok, bool resolveType, bool resolveScope)
15751574{
15761575 Q_ASSERT (ok);
15771576 *ok = true ;
@@ -1581,7 +1580,7 @@ AbstractMetaType *AbstractMetaBuilder::translateType(const TypeInfo &_typei, boo
15811580 TypeInfo typei;
15821581 if (resolveType) {
15831582 bool isok;
1584- AbstractMetaType * t = translateType (_typei, &isok, false , resolveScope);
1583+ AbstractMetaType::shared_pointer t = translateType (_typei, &isok, false , resolveScope);
15851584 if (t != 0 && isok)
15861585 return t;
15871586 }
@@ -1632,7 +1631,7 @@ AbstractMetaType *AbstractMetaBuilder::translateType(const TypeInfo &_typei, boo
16321631 newInfo.setVolatile (typei.isVolatile ());
16331632 newInfo.setMutable (typei.isMutable ());
16341633
1635- AbstractMetaType * elementType = translateType (newInfo, ok);
1634+ AbstractMetaType::shared_pointer elementType = translateType (newInfo, ok);
16361635 if (!(*ok))
16371636 return 0 ;
16381637
@@ -1644,7 +1643,7 @@ AbstractMetaType *AbstractMetaBuilder::translateType(const TypeInfo &_typei, boo
16441643 if (!isok)
16451644 return 0 ;
16461645
1647- AbstractMetaType * arrayType = createMetaType ();
1646+ AbstractMetaType::shared_pointer arrayType = createMetaType ();
16481647 arrayType->setArrayElementCount (elems);
16491648 arrayType->setArrayElementType (elementType);
16501649 arrayType->setTypeEntry (new ArrayTypeEntry (elementType->typeEntry ()));
@@ -1714,7 +1713,7 @@ AbstractMetaType *AbstractMetaBuilder::translateType(const TypeInfo &_typei, boo
17141713
17151714 bool isok;
17161715 info.setQualifiedName (QStringList () << contexts.at (0 ) << qualified_name);
1717- AbstractMetaType * t = translateType (info, &isok, true , false );
1716+ AbstractMetaType::shared_pointer t = translateType (info, &isok, true , false );
17181717 if (t != 0 && isok)
17191718 return t;
17201719
@@ -1744,7 +1743,7 @@ AbstractMetaType *AbstractMetaBuilder::translateType(const TypeInfo &_typei, boo
17441743 // These are only implicit and should not appear in code...
17451744 Q_ASSERT (!type->isInterface ());
17461745
1747- AbstractMetaType * meta_type = createMetaType ();
1746+ AbstractMetaType::shared_pointer meta_type = createMetaType ();
17481747 meta_type->setTypeEntry (type);
17491748 meta_type->setIndirections (typeInfo.indirections );
17501749 meta_type->setReference (typeInfo.is_reference );
@@ -1778,7 +1777,6 @@ AbstractMetaType *AbstractMetaBuilder::translateType(const TypeInfo &_typei, boo
17781777
17791778 AbstractMetaType::shared_pointer targ_type (translateType (info, ok));
17801779 if (!(*ok)) {
1781- delete meta_type;
17821780 return 0 ;
17831781 }
17841782
@@ -1796,7 +1794,7 @@ AbstractMetaType *AbstractMetaBuilder::translateType(const TypeInfo &_typei, boo
17961794 return meta_type;
17971795}
17981796
1799- void AbstractMetaBuilder::decideUsagePattern (AbstractMetaType * meta_type)
1797+ void AbstractMetaBuilder::decideUsagePattern (AbstractMetaType::shared_pointer meta_type)
18001798{
18011799 const TypeEntry *type = meta_type->typeEntry ();
18021800
@@ -1882,7 +1880,7 @@ void AbstractMetaBuilder::decideUsagePattern(AbstractMetaType *meta_type)
18821880 }
18831881}
18841882
1885- QString AbstractMetaBuilder::translateDefaultValue (ArgumentModelItem item, AbstractMetaType * type,
1883+ QString AbstractMetaBuilder::translateDefaultValue (ArgumentModelItem item, AbstractMetaType::shared_pointer type,
18861884 AbstractMetaFunction *fnc, AbstractMetaClass *implementing_class,
18871885 int argument_index)
18881886{
@@ -1938,16 +1936,16 @@ bool AbstractMetaBuilder::isEnum(const QStringList &qualified_name)
19381936 return item && item->kind () == _EnumModelItem::__node_kind;
19391937}
19401938
1941- AbstractMetaType * AbstractMetaBuilder::inheritTemplateType (const QList<AbstractMetaType * > &template_types,
1942- AbstractMetaType * meta_type, bool *ok)
1939+ AbstractMetaType::shared_pointer AbstractMetaBuilder::inheritTemplateType (const QList<AbstractMetaType::shared_pointer > &template_types,
1940+ AbstractMetaType::shared_pointer meta_type, bool *ok)
19431941{
19441942 if (ok != 0 )
19451943 *ok = true ;
19461944 if (!meta_type || (!meta_type->typeEntry ()->isTemplateArgument () && !meta_type->hasInstantiations ()))
1947- return meta_type ? meta_type-> copy () : 0 ;
1945+ return meta_type ? meta_type : 0 ;
19481946
1949- AbstractMetaType * returned = meta_type-> copy () ;
1950- returned->setOriginalTemplateType (meta_type-> copy () );
1947+ AbstractMetaType::shared_pointer returned = meta_type;
1948+ returned->setOriginalTemplateType (meta_type);
19511949
19521950 if (returned->typeEntry ()->isTemplateArgument ()) {
19531951 const TemplateArgumentEntry *tae = static_cast <const TemplateArgumentEntry *>(returned->typeEntry ());
@@ -1960,14 +1958,13 @@ AbstractMetaType *AbstractMetaBuilder::inheritTemplateType(const QList<AbstractM
19601958 return 0 ;
19611959 }
19621960
1963- AbstractMetaType * t = returned-> copy () ;
1961+ AbstractMetaType::shared_pointer t = returned;
19641962 t->setTypeEntry (template_types.at (tae->ordinal ())->typeEntry ());
19651963 t->setIndirections (template_types.at (tae->ordinal ())->indirections () + t->indirections ()
19661964 ? 1
19671965 : 0 );
19681966 decideUsagePattern (t);
19691967
1970- delete returned;
19711968 returned = inheritTemplateType (template_types, t, ok);
19721969 if (ok != 0 && !(*ok))
19731970 return 0 ;
@@ -1976,7 +1973,7 @@ AbstractMetaType *AbstractMetaBuilder::inheritTemplateType(const QList<AbstractM
19761973 if (returned->hasInstantiations ()) {
19771974 auto instantiations = returned->instantiations ();
19781975 for (int i=0 ; i<instantiations.count (); ++i) {
1979- instantiations[i] = AbstractMetaType::shared_pointer (inheritTemplateType (template_types, instantiations[i]. data () , ok));
1976+ instantiations[i] = AbstractMetaType::shared_pointer (inheritTemplateType (template_types, instantiations[i], ok));
19801977 if (ok != 0 && !(*ok))
19811978 return 0 ;
19821979 }
@@ -1992,12 +1989,12 @@ bool AbstractMetaBuilder::inheritTemplate(AbstractMetaClass *subclass,
19921989{
19931990 QList<TypeParser::Info> targs = info.template_instantiations ;
19941991
1995- QList<AbstractMetaType * > template_types;
1992+ QList<AbstractMetaType::shared_pointer > template_types;
19961993 for (const TypeParser::Info &i : targs) {
19971994 TypeEntry *t = TypeDatabase::instance ()->findType (i.qualified_name .join (" ::" ));
19981995
19991996 if (t != 0 ) {
2000- AbstractMetaType * temporary_type = createMetaType ();
1997+ AbstractMetaType::shared_pointer temporary_type = createMetaType ();
20011998 temporary_type->setTypeEntry (t);
20021999 temporary_type->setConstant (i.is_constant );
20032000 temporary_type->setReference (i.is_reference );
@@ -2016,15 +2013,15 @@ bool AbstractMetaBuilder::inheritTemplate(AbstractMetaClass *subclass,
20162013 f->setArguments (AbstractMetaArgumentList ());
20172014
20182015 bool ok = true ;
2019- AbstractMetaType * ftype = function->type ();
2016+ AbstractMetaType::shared_pointer ftype = function->type ();
20202017 f->setType (inheritTemplateType (template_types, ftype, &ok));
20212018 if (!ok) {
20222019 delete f;
20232020 continue ;
20242021 }
20252022
20262023 for (AbstractMetaArgument *argument : function->arguments ()) {
2027- AbstractMetaType * atype = argument->type ();
2024+ AbstractMetaType::shared_pointer atype = argument->type ();
20282025
20292026 AbstractMetaArgument *arg = argument->copy ();
20302027 arg->setType (inheritTemplateType (template_types, atype, &ok));
@@ -2096,12 +2093,6 @@ bool AbstractMetaBuilder::inheritTemplate(AbstractMetaClass *subclass,
20962093 subclass->addFunction (f);
20972094 }
20982095
2099- // Clean up
2100- for (AbstractMetaType *type : template_types) {
2101- delete type;
2102- }
2103-
2104-
21052096 {
21062097 subclass->setTemplateBaseClass (template_class);
21072098
@@ -2122,7 +2113,7 @@ void AbstractMetaBuilder::parseQ_Property(AbstractMetaClass *meta_class, const Q
21222113
21232114 QStringList qualifiedScopeName = currentScope ()->qualifiedName ();
21242115 bool ok = false ;
2125- AbstractMetaType * type = 0 ;
2116+ AbstractMetaType::shared_pointer type = 0 ;
21262117 int pIndex = 0 ;
21272118 QString typeName = l.value (pIndex++);
21282119 bool isConst = false ;
@@ -2179,7 +2170,6 @@ void AbstractMetaBuilder::parseQ_Property(AbstractMetaClass *meta_class, const Q
21792170 }
21802171
21812172 meta_class->addPropertySpec (spec);
2182- delete type;
21832173 }
21842174}
21852175
0 commit comments