diff options
author | Lauro Neto <lauro.neto@openbossa.org> | 2010-10-05 14:31:14 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-09 19:10:11 -0300 |
commit | bf3a54b93944ae86f82db2e49ccffe8efdaa3517 (patch) | |
tree | 73096744a54ad17632ca9cc5ffaeaf62195b81c2 /abstractmetabuilder.cpp | |
parent | 8db091fd280d5e965c90b2da4b26dd030e4b0f54 (diff) |
Better qproperty function check
Now checking for the full specs:
Getter: TYPE name(void)
Setter: void name(TYPE)
Resetter: void name(void)
The previous behavior was crashing when there is a different
overload with the same name of one of the property functions.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'abstractmetabuilder.cpp')
-rw-r--r-- | abstractmetabuilder.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp index f90729ce1..60b687a63 100644 --- a/abstractmetabuilder.cpp +++ b/abstractmetabuilder.cpp @@ -1341,20 +1341,26 @@ void AbstractMetaBuilder::traverseFunctions(ScopeModelItem scopeItem, AbstractMe if (metaClass->isNamespace()) *metaFunction += AbstractMetaAttributes::Static; - if (QPropertySpec* read = metaClass->propertySpecForRead(metaFunction->name())) { - if (read->type() == metaFunction->type()->typeEntry()) { + QPropertySpec *read = 0; + if (!metaFunction->isSignal() && (read = metaClass->propertySpecForRead(metaFunction->name()))) { + // Property reader must be in the form "<type> name()" + if (metaFunction->type() && (read->type() == metaFunction->type()->typeEntry()) && (metaFunction->arguments().size() == 0)) { *metaFunction += AbstractMetaAttributes::PropertyReader; metaFunction->setPropertySpec(read); } } else if (QPropertySpec* write = metaClass->propertySpecForWrite(metaFunction->name())) { + // Property setter must be in the form "void name(<type>)" // make sure the function was created with all aguments, some argument can be missing during the pareser because of errors on typesystem - if ((metaFunction->arguments().size() == 1) && (write->type() == metaFunction->arguments().at(0)->type()->typeEntry())) { + if ((!metaFunction->type()) && (metaFunction->arguments().size() == 1) && (write->type() == metaFunction->arguments().at(0)->type()->typeEntry())) { *metaFunction += AbstractMetaAttributes::PropertyWriter; metaFunction->setPropertySpec(write); } } else if (QPropertySpec* reset = metaClass->propertySpecForReset(metaFunction->name())) { - *metaFunction += AbstractMetaAttributes::PropertyResetter; - metaFunction->setPropertySpec(reset); + // Property resetter must be in the form "void name()" + if ((!metaFunction->type()) && (metaFunction->arguments().size() == 0)) { + *metaFunction += AbstractMetaAttributes::PropertyResetter; + metaFunction->setPropertySpec(reset); + } } // Can not use metaFunction->isCopyConstructor() because |