1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

Don't call non-const member functions on temporaries

They can detach if the container is shared. Even if they are not shared,
using const method when possible is good practice.

Differential Revision: https://phabricator.kde.org/D9730
This commit is contained in:
Luís Pereira 2018-01-11 19:05:41 +01:00 committed by David Rosca
parent 26307bd387
commit 0096801556
3 changed files with 12 additions and 12 deletions

View File

@ -219,7 +219,7 @@ QMenu* LineEdit::createContextMenu()
QMenu* tmp = createStandardContextMenu(); QMenu* tmp = createStandardContextMenu();
tmp->setParent(popup); tmp->setParent(popup);
tmp->hide(); tmp->hide();
QAction* lastAction = !tmp->actions().isEmpty() ? tmp->actions().last() : 0; QAction* lastAction = !tmp->actions().isEmpty() ? tmp->actions().constLast() : 0;
if (lastAction && lastAction->menu() && lastAction->menu()->inherits("QUnicodeControlCharacterMenu")) { if (lastAction && lastAction->menu() && lastAction->menu()->inherits("QUnicodeControlCharacterMenu")) {
popup->addAction(lastAction); popup->addAction(lastAction);

View File

@ -189,7 +189,7 @@ void CommandLineOptions::parseActions()
if (parser.positionalArguments().isEmpty()) if (parser.positionalArguments().isEmpty())
return; return;
QString url = parser.positionalArguments().last(); QString url = parser.positionalArguments().constLast();
QFileInfo fileInfo(url); QFileInfo fileInfo(url);
if (fileInfo.exists()) { if (fileInfo.exists()) {

View File

@ -96,14 +96,14 @@ void PasswordBackendTest::storeTest()
m_backend->addEntry(entry); m_backend->addEntry(entry);
// Check entry that may be stored in cache // Check entry that may be stored in cache
PasswordEntry stored = m_backend->getEntries(QUrl("org.qupzilla.google.com")).first(); PasswordEntry stored = m_backend->getEntries(QUrl("org.qupzilla.google.com")).constFirst();
QVERIFY(compareEntries(stored, entry) == true); QVERIFY(compareEntries(stored, entry) == true);
reloadBackend(); reloadBackend();
// Check entry retrieved from backend engine // Check entry retrieved from backend engine
QVERIFY(!m_backend->getEntries(QUrl("org.qupzilla.google.com")).isEmpty()); QVERIFY(!m_backend->getEntries(QUrl("org.qupzilla.google.com")).isEmpty());
stored = m_backend->getEntries(QUrl("org.qupzilla.google.com")).first(); stored = m_backend->getEntries(QUrl("org.qupzilla.google.com")).constFirst();
QVERIFY(compareEntries(stored, entry) == true); QVERIFY(compareEntries(stored, entry) == true);
@ -118,13 +118,13 @@ void PasswordBackendTest::storeTest()
m_backend->addEntry(entry2); m_backend->addEntry(entry2);
// Check entry that may be stored in cache // Check entry that may be stored in cache
PasswordEntry stored2 = m_backend->getEntries(QUrl("org.qupzilla.qupzilla.com")).first(); PasswordEntry stored2 = m_backend->getEntries(QUrl("org.qupzilla.qupzilla.com")).constFirst();
QVERIFY(compareEntries(stored2, entry2) == true); QVERIFY(compareEntries(stored2, entry2) == true);
reloadBackend(); reloadBackend();
// Check entry retrieved from backend engine // Check entry retrieved from backend engine
stored2 = m_backend->getEntries(QUrl("org.qupzilla.qupzilla.com")).first(); stored2 = m_backend->getEntries(QUrl("org.qupzilla.qupzilla.com")).constFirst();
QVERIFY(compareEntries(stored2, entry2) == true); QVERIFY(compareEntries(stored2, entry2) == true);
/* Cleanup */ /* Cleanup */
@ -203,13 +203,13 @@ void PasswordBackendTest::updateLastUsedTest()
m_backend->addEntry(entry); m_backend->addEntry(entry);
QVERIFY(!m_backend->getEntries(QUrl("org.qupzilla.google.com")).isEmpty()); QVERIFY(!m_backend->getEntries(QUrl("org.qupzilla.google.com")).isEmpty());
QVERIFY(compareEntries(entry, m_backend->getEntries(QUrl("org.qupzilla.google.com")).first())); QVERIFY(compareEntries(entry, m_backend->getEntries(QUrl("org.qupzilla.google.com")).constFirst()));
reloadBackend(); reloadBackend();
QVERIFY(!m_backend->getEntries(QUrl("org.qupzilla.google.com")).isEmpty()); QVERIFY(!m_backend->getEntries(QUrl("org.qupzilla.google.com")).isEmpty());
QVERIFY(compareEntries(entry, m_backend->getEntries(QUrl("org.qupzilla.google.com")).first())); QVERIFY(compareEntries(entry, m_backend->getEntries(QUrl("org.qupzilla.google.com")).constFirst()));
m_backend->removeEntry(m_backend->getEntries(QUrl("org.qupzilla.google.com")).first()); m_backend->removeEntry(m_backend->getEntries(QUrl("org.qupzilla.google.com")).constFirst());
m_backend->removeEntry(m_backend->getEntries(QUrl("org.qupzilla.google.com")).first()); m_backend->removeEntry(m_backend->getEntries(QUrl("org.qupzilla.google.com")).constFirst());
QCOMPARE(m_backend->getAllEntries().count(), 0); QCOMPARE(m_backend->getAllEntries().count(), 0);
reloadBackend(); reloadBackend();
@ -284,7 +284,7 @@ void KWalletPasswordBackendTest::init()
msg << quint32(0); msg << quint32(0);
QDBusMessage reply = QDBusConnection::sessionBus().call(msg); QDBusMessage reply = QDBusConnection::sessionBus().call(msg);
if (reply.arguments().isEmpty() || reply.arguments().first().toInt() != 1) if (reply.arguments().isEmpty() || reply.arguments().constFirst().toInt() != 1)
QSKIP("This test requires org.kde.kwalletd5 service."); QSKIP("This test requires org.kde.kwalletd5 service.");
} }
@ -307,7 +307,7 @@ void GnomeKeyringPasswordBackendTest::init()
msg << quint32(0); msg << quint32(0);
QDBusMessage reply = QDBusConnection::sessionBus().call(msg); QDBusMessage reply = QDBusConnection::sessionBus().call(msg);
if (reply.arguments().isEmpty() || reply.arguments().first().toInt() != 1) if (reply.arguments().isEmpty() || reply.arguments().constFirst().toInt() != 1)
QSKIP("This test requires org.freedesktop.secrets service."); QSKIP("This test requires org.freedesktop.secrets service.");
} }