Avoid detaching temporary objects

Found with clazy [detaching-temporary]:
- don't call QList::first() on temporary
- don't call QString::operator[]() on temporary
- don't call QByteArray::data() on temporary

Change-Id: I390962ef6020e4fcb0b0e447a63eed1e314d18a4
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Sérgio Martins <sergio.martins@kdab.com>
bb10
Alexander Volkov 2017-01-17 14:48:08 +03:00
parent 0c415793b9
commit 69e233d2ba
6 changed files with 6 additions and 6 deletions

View File

@ -629,7 +629,7 @@ QString QFSFileEngine::fileName(FileName file) const
bool QFSFileEngine::isRelativePath() const
{
Q_D(const QFSFileEngine);
return d->fileEntry.filePath().length() ? d->fileEntry.filePath()[0] != QLatin1Char('/') : true;
return d->fileEntry.filePath().length() ? d->fileEntry.filePath().at(0) != QLatin1Char('/') : true;
}
uint QFSFileEngine::ownerId(FileOwner own) const

View File

@ -606,7 +606,7 @@ QString QNetworkDiskCachePrivate::uniqueFileName(const QUrl &url)
QCryptographicHash hash(QCryptographicHash::Sha1);
hash.addData(cleanUrl.toEncoded());
// convert sha1 to base36 form and return first 8 bytes for use as string
QByteArray id = QByteArray::number(*(qlonglong*)hash.result().data(), 36).left(8);
const QByteArray id = QByteArray::number(*(qlonglong*)hash.result().constData(), 36).left(8);
// generates <one-char subdir>/<8-char filname.d>
uint code = (uint)id.at(id.length()-1) % 16;
QString pathFragment = QString::number(code, 16) + QLatin1Char('/')

View File

@ -1398,7 +1398,7 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
sendReply(connection, message, QVariant::fromValue(
QDBusVariant(QVariant::fromValue(QSpiObjectReference(connection, QDBusObjectPath(path))))));
} else if (function == QLatin1String("GetChildAtIndex")) {
int index = message.arguments().first().toInt();
const int index = message.arguments().at(0).toInt();
if (index < 0) {
sendReply(connection, message, QVariant::fromValue(
QSpiObjectReference(connection, QDBusObjectPath(ATSPI_DBUS_PATH_NULL))));

View File

@ -115,7 +115,7 @@ int runUic(int argc, char *argv[])
QString inputFile;
if (!parser.positionalArguments().isEmpty())
inputFile = parser.positionalArguments().first();
inputFile = parser.positionalArguments().at(0);
else // reading from stdin
driver.option().headerProtection = false;

View File

@ -765,7 +765,7 @@ bool QCalendarTextNavigator::eventFilter(QObject *o, QEvent *e)
if (m_widget) {
if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) {
QKeyEvent* ke = (QKeyEvent*)e;
if ((ke->text().length() > 0 && ke->text()[0].isPrint()) || m_dateFrame) {
if ((ke->text().length() > 0 && ke->text().at(0).isPrint()) || m_dateFrame) {
if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Select) {
applyDate();
emit editingFinished();

View File

@ -1119,7 +1119,7 @@ void QMenuBar::keyPressEvent(QKeyEvent *e)
int clashCount = 0;
QAction *first = 0, *currentSelected = 0, *firstAfterCurrent = 0;
{
QChar c = e->text()[0].toUpper();
const QChar c = e->text().at(0).toUpper();
for(int i = 0; i < d->actions.size(); ++i) {
if (d->actionRects.at(i).isNull())
continue;