Use QMetaEnum::fromType() instead of staticMetaObject.enumerator()

The old way relied on the order of enums within the type; using
fromType() makes the enum specific.

Change-Id: I418473a6983861ca105ccc5eb249f441dbbb28cf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Edward Welbourne 2025-06-06 16:09:13 +02:00
parent f67ef4934b
commit 3905d3c4df

View File

@ -124,9 +124,7 @@ void tst_QCalendar::basic_data()
{
QTest::addColumn<QCalendar::System>("system");
QMetaEnum e = QCalendar::staticMetaObject.enumerator(0);
Q_ASSERT(qstrcmp(e.name(), "System") == 0);
const QMetaEnum e = QMetaEnum::fromType<QCalendar::System>();
for (int i = 0; i <= int(QCalendar::System::Last); ++i) {
// There may be gaps in the enum's numbering; and Last is a duplicate:
if (e.value(i) != -1 && qstrcmp(e.key(i), "Last"))