QMetaProperty: use early return
This improves readability. Change-Id: I6552463b5f14d79b99efd3c0633695401bdb7f78 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
ba6c1d2785
commit
e441985534
@ -3182,37 +3182,37 @@ QMetaProperty::QMetaProperty(const QMetaObject *mobj, int index)
|
|||||||
{
|
{
|
||||||
Q_ASSERT(index >= 0 && index < priv(mobj->d.data)->propertyCount);
|
Q_ASSERT(index >= 0 && index < priv(mobj->d.data)->propertyCount);
|
||||||
|
|
||||||
if (data.flags() & EnumOrFlag) {
|
if (!(data.flags() & EnumOrFlag))
|
||||||
const char *type = rawTypeNameFromTypeInfo(mobj, data.type());
|
return;
|
||||||
menum = mobj->enumerator(mobj->indexOfEnumerator(type));
|
const char *type = rawTypeNameFromTypeInfo(mobj, data.type());
|
||||||
if (!menum.isValid()) {
|
menum = mobj->enumerator(mobj->indexOfEnumerator(type));
|
||||||
const char *enum_name = type;
|
if (menum.isValid())
|
||||||
const char *scope_name = objectClassName(mobj);
|
return;
|
||||||
char *scope_buffer = nullptr;
|
const char *enum_name = type;
|
||||||
|
const char *scope_name = objectClassName(mobj);
|
||||||
|
char *scope_buffer = nullptr;
|
||||||
|
|
||||||
const char *colon = strrchr(enum_name, ':');
|
const char *colon = strrchr(enum_name, ':');
|
||||||
// ':' will always appear in pairs
|
// ':' will always appear in pairs
|
||||||
Q_ASSERT(colon <= enum_name || *(colon - 1) == ':');
|
Q_ASSERT(colon <= enum_name || *(colon - 1) == ':');
|
||||||
if (colon > enum_name) {
|
if (colon > enum_name) {
|
||||||
int len = colon - enum_name - 1;
|
int len = colon - enum_name - 1;
|
||||||
scope_buffer = (char *)malloc(len + 1);
|
scope_buffer = (char *)malloc(len + 1);
|
||||||
memcpy(scope_buffer, enum_name, len);
|
memcpy(scope_buffer, enum_name, len);
|
||||||
scope_buffer[len] = '\0';
|
scope_buffer[len] = '\0';
|
||||||
scope_name = scope_buffer;
|
scope_name = scope_buffer;
|
||||||
enum_name = colon + 1;
|
enum_name = colon + 1;
|
||||||
}
|
|
||||||
|
|
||||||
const QMetaObject *scope = nullptr;
|
|
||||||
if (qstrcmp(scope_name, "Qt") == 0)
|
|
||||||
scope = &Qt::staticMetaObject;
|
|
||||||
else
|
|
||||||
scope = QMetaObject_findMetaObject(mobj, scope_name);
|
|
||||||
if (scope)
|
|
||||||
menum = scope->enumerator(scope->indexOfEnumerator(enum_name));
|
|
||||||
if (scope_buffer)
|
|
||||||
free(scope_buffer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QMetaObject *scope = nullptr;
|
||||||
|
if (qstrcmp(scope_name, "Qt") == 0)
|
||||||
|
scope = &Qt::staticMetaObject;
|
||||||
|
else
|
||||||
|
scope = QMetaObject_findMetaObject(mobj, scope_name);
|
||||||
|
if (scope)
|
||||||
|
menum = scope->enumerator(scope->indexOfEnumerator(enum_name));
|
||||||
|
if (scope_buffer)
|
||||||
|
free(scope_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user