From 67c800af6e879757e6b78de7b47844050a84b941 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 8 Oct 2020 13:49:42 +0200 Subject: [PATCH] PerfProfiler: Some Qt6 compilation Remaining issues operator<<(DataStream &...), the timeline dependency and qmlRegisterType. Change-Id: I51556e67cd93cb8bdced569ca509929705da80b4 Reviewed-by: Ulf Hermann --- .../perfprofiler/perfconfigeventsmodel.cpp | 2 +- src/plugins/perfprofiler/perftimelinemodel.cpp | 4 ++-- .../tests/perfresourcecounter_test.cpp | 17 ++++++++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/plugins/perfprofiler/perfconfigeventsmodel.cpp b/src/plugins/perfprofiler/perfconfigeventsmodel.cpp index 304adfa4a52..d6876b4774b 100644 --- a/src/plugins/perfprofiler/perfconfigeventsmodel.cpp +++ b/src/plugins/perfprofiler/perfconfigeventsmodel.cpp @@ -355,7 +355,7 @@ PerfConfigEventsModel::EventDescription PerfConfigEventsModel::parseEvent( if (event.startsWith('r') && event.length() == 4) { bool ok = false; - const uint eventNumber = event.midRef(1).toUInt(&ok, 16); + const uint eventNumber = QStringView{event}.mid(1).toUInt(&ok, 16); if (ok) { description.eventType = EventTypeRaw; description.numericEvent = eventNumber; diff --git a/src/plugins/perfprofiler/perftimelinemodel.cpp b/src/plugins/perfprofiler/perftimelinemodel.cpp index 234338ffe38..44083eea18e 100644 --- a/src/plugins/perfprofiler/perftimelinemodel.cpp +++ b/src/plugins/perfprofiler/perftimelinemodel.cpp @@ -179,8 +179,8 @@ QVariantMap PerfTimelineModel::details(int index) const result.insert(tr("Name"), orUnknown(manager->string(tracePoint.name))); const QHash &extraData = m_extraData[index]; for (auto it = extraData.constBegin(), end = extraData.constEnd(); it != end; ++it) { - result.insertMulti(QString::fromUtf8(manager->string(it.key())), - prettyPrintTraceData(it.value())); + result.insert(QString::fromUtf8(manager->string(it.key())), + prettyPrintTraceData(it.value())); } } if (!m_resourceBlocks.isEmpty()) { diff --git a/src/plugins/perfprofiler/tests/perfresourcecounter_test.cpp b/src/plugins/perfprofiler/tests/perfresourcecounter_test.cpp index f48d6aec45c..fc44c0e60f5 100644 --- a/src/plugins/perfprofiler/tests/perfresourcecounter_test.cpp +++ b/src/plugins/perfprofiler/tests/perfresourcecounter_test.cpp @@ -112,19 +112,20 @@ void PerfResourceCounterTest::testMallocFree() void PerfResourceCounterTest::testRandomFill() { + auto rg = QRandomGenerator::global(); for (int i = 0; i < 100; ++i) { SizeCounter::Container container; SizeCounter counter(&container); for (int i = 0; i < 10000; ++i) { - const int amount = qrand(); + const int amount = rg->generate(); counter.request(amount, i); - counter.obtain(qrand()); + counter.obtain(rg->generate()); if (sum(container) != counter.currentTotal()) qDebug() << "ouch"; QCOMPARE(sum(container), counter.currentTotal()); } for (int i = 0; i < 10000; ++i) { - counter.release(qrand()); + counter.release(rg->generate()); QCOMPARE(sum(container), counter.currentTotal()); } @@ -138,9 +139,10 @@ void PerfResourceCounterTest::testUnitSized() NoPayloadCounter::Container container; NoPayloadCounter counter(&container); QList ids; + auto rg = QRandomGenerator::global(); for (int i = 0; i < 10000; ++i) { counter.request(1); - const int id = qrand(); + const int id = rg->generate(); counter.obtain(id); if (id != 0) // Otherwise it's the invalid ID and that means the allocation "failed". ids.append(id); @@ -158,11 +160,12 @@ void PerfResourceCounterTest::testRandomAlternate() { NoPayloadCounter::Container container; NoPayloadCounter counter(&container); + auto rg = QRandomGenerator::global(); for (int i = 0; i < 1000; ++i) { for (int i = 0; i < 100; ++i) { - counter.request(qrand()); - counter.obtain(qrand()); - counter.release(qrand()); + counter.request(rg->generate()); + counter.obtain(rg->generate()); + counter.release(rg->generate()); } QCOMPARE(sum(container), counter.currentTotal()); }