Skip to content

Commit

Permalink
Cleanup QMetaClassInfo
Browse files Browse the repository at this point in the history
Change-Id: I0b4fa4568f8479106053e0fae72fc802fca74a65
Reviewed-by: Ulf Hermann <[email protected]>
  • Loading branch information
laknoll authored and Inkane committed Jun 11, 2020
1 parent 630c7b4 commit f5e8f9c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/corelib/kernel/qmetaobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ QMetaClassInfo QMetaObject::classInfo(int index) const
QMetaClassInfo result;
if (i >= 0 && i < priv(d.data)->classInfoCount) {
result.mobj = this;
result.handle = priv(d.data)->classInfoData + 2*i;
result.data = { d.data + priv(d.data)->classInfoData + i * QMetaClassInfo::Data::Size };
}
return result;
}
Expand Down Expand Up @@ -3554,7 +3554,7 @@ const char *QMetaClassInfo::name() const
{
if (!mobj)
return nullptr;
return rawStringData(mobj, mobj->d.data[handle]);
return rawStringData(mobj, data.name());
}

/*!
Expand All @@ -3566,7 +3566,7 @@ const char* QMetaClassInfo::value() const
{
if (!mobj)
return nullptr;
return rawStringData(mobj, mobj->d.data[handle + 1]);
return rawStringData(mobj, data.value());
}

/*!
Expand Down
13 changes: 11 additions & 2 deletions src/corelib/kernel/qmetaobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,22 @@ class Q_CORE_EXPORT QMetaProperty
class Q_CORE_EXPORT QMetaClassInfo
{
public:
Q_DECL_CONSTEXPR inline QMetaClassInfo() : mobj(nullptr), handle(0) {}
Q_DECL_CONSTEXPR inline QMetaClassInfo() : mobj(nullptr), data({ nullptr }) {}
const char *name() const;
const char *value() const;
inline const QMetaObject *enclosingMetaObject() const { return mobj; }
private:
struct Data {
enum { Size = 2 };

uint name() const { return d[0]; }
uint value() const { return d[1]; }

const uint *d;
};

const QMetaObject *mobj;
uint handle;
Data data;
friend struct QMetaObject;
};
Q_DECLARE_TYPEINFO(QMetaClassInfo, Q_MOVABLE_TYPE);
Expand Down

0 comments on commit f5e8f9c

Please sign in to comment.