From bcb54bc38aa3392fa599cfc29f4ec84e4794bf35 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Fri, 25 Sep 2015 21:33:55 +0200 Subject: [PATCH] Avoid dereferencing QLists. --- src/gui/entry/EntryModel.cpp | 2 +- src/gui/group/GroupModel.cpp | 2 +- tests/TestEntry.cpp | 2 +- tests/TestExporter.cpp | 6 +++--- tests/TestKeePass1Reader.cpp | 4 ++-- tests/TestKeePass2XmlReader.cpp | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gui/entry/EntryModel.cpp b/src/gui/entry/EntryModel.cpp index 7ee1df8fb..c75d38a1b 100644 --- a/src/gui/entry/EntryModel.cpp +++ b/src/gui/entry/EntryModel.cpp @@ -239,7 +239,7 @@ QMimeData* EntryModel::mimeData(const QModelIndexList& indexes) const return Q_NULLPTR; } else { - data->setData(mimeTypes().first(), encoded); + data->setData(mimeTypes().at(0), encoded); return data; } } diff --git a/src/gui/group/GroupModel.cpp b/src/gui/group/GroupModel.cpp index b33a5ff54..21f8c7e3b 100644 --- a/src/gui/group/GroupModel.cpp +++ b/src/gui/group/GroupModel.cpp @@ -357,7 +357,7 @@ QMimeData* GroupModel::mimeData(const QModelIndexList& indexes) const return Q_NULLPTR; } else { - data->setData(mimeTypes().first(), encoded); + data->setData(mimeTypes().at(0), encoded); return data; } } diff --git a/tests/TestEntry.cpp b/tests/TestEntry.cpp index 477e83b86..f918b6ccc 100644 --- a/tests/TestEntry.cpp +++ b/tests/TestEntry.cpp @@ -120,6 +120,6 @@ void TestEntry::testClone() QCOMPARE(entryCloneNone->uuid(), entryOrg->uuid()); QCOMPARE(entryCloneHistory->title(), QString("New Title")); QCOMPARE(entryCloneHistory->historyItems().size(), 1); - QCOMPARE(entryCloneHistory->historyItems().first()->title(), QString("Original Title")); + QCOMPARE(entryCloneHistory->historyItems().at(0)->title(), QString("Original Title")); QCOMPARE(entryCloneHistory->timeInfo().creationTime(), entryOrg->timeInfo().creationTime()); } diff --git a/tests/TestExporter.cpp b/tests/TestExporter.cpp index d703e02f1..76a6f75c3 100644 --- a/tests/TestExporter.cpp +++ b/tests/TestExporter.cpp @@ -60,19 +60,19 @@ void TestExporter::testToDbExporter() Database* dbExp = ToDbExporter().exportGroup(groupOrg); QCOMPARE(dbExp->rootGroup()->children().size(), 1); - Group* groupExp = dbExp->rootGroup()->children().first(); + Group* groupExp = dbExp->rootGroup()->children().at(0); QVERIFY(groupExp != groupOrg); QCOMPARE(groupExp->name(), groupOrg->name()); QCOMPARE(groupExp->entries().size(), 1); - Entry* entryExp = groupExp->entries().first(); + Entry* entryExp = groupExp->entries().at(0); QCOMPARE(entryExp->title(), entryOrg->title()); QCOMPARE(dbExp->metadata()->customIcons().size(), 1); QVERIFY(dbExp->metadata()->containsCustomIcon(iconUuid)); QCOMPARE(entryExp->iconNumber(), entryOrg->iconNumber()); QCOMPARE(entryExp->historyItems().size(), 1); - QCOMPARE(entryExp->historyItems().first()->iconUuid(), iconUuid); + QCOMPARE(entryExp->historyItems().at(0)->iconUuid(), iconUuid); delete dbOrg; delete dbExp; diff --git a/tests/TestKeePass1Reader.cpp b/tests/TestKeePass1Reader.cpp index 249a3657b..d9dff9e41 100644 --- a/tests/TestKeePass1Reader.cpp +++ b/tests/TestKeePass1Reader.cpp @@ -71,7 +71,7 @@ void TestKeePass1Reader::testBasic() QVERIFY(entry11->timeInfo().expires()); QCOMPARE(entry11->timeInfo().expiryTime(), genDT(2012, 5, 9, 10, 32)); QCOMPARE(entry11->attachments()->keys().size(), 1); - QCOMPARE(entry11->attachments()->keys().first(), QString("attachment.txt")); + QCOMPARE(entry11->attachments()->keys().at(0), QString("attachment.txt")); QCOMPARE(entry11->attachments()->value("attachment.txt"), QByteArray("hello world\n")); Entry* entry12 = group1->entries().at(1); @@ -118,7 +118,7 @@ void TestKeePass1Reader::testCustomIcons() { QCOMPARE(m_db->metadata()->customIcons().size(), 1); - Entry* entry = m_db->rootGroup()->children().at(1)->entries().first(); + Entry* entry = m_db->rootGroup()->children().at(1)->entries().at(0); QCOMPARE(entry->icon().width(), 16); QCOMPARE(entry->icon().height(), 16); diff --git a/tests/TestKeePass2XmlReader.cpp b/tests/TestKeePass2XmlReader.cpp index b458761db..81690009e 100644 --- a/tests/TestKeePass2XmlReader.cpp +++ b/tests/TestKeePass2XmlReader.cpp @@ -315,7 +315,7 @@ void TestKeePass2XmlReader::testEntry2() void TestKeePass2XmlReader::testEntryHistory() { - const Entry* entryMain = m_db->rootGroup()->entries().first(); + const Entry* entryMain = m_db->rootGroup()->entries().at(0); QCOMPARE(entryMain->historyItems().size(), 2); {