From 1d8030cc64df2cdfdc0faf3d06ea7d9ed0306948 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 30 Dec 2015 02:04:26 +0100 Subject: QtWidgets: prevent detach attempts from first()/etc. use [dialogs, kernel, util, widgets] The algorithm used was: - If possible, just declare the container const - Otherwise, for first()/last(), use constFirst()/constLast() and for front()/back(), to not destroy the use of the STL API subset, use qAsConst() Did some caching of function returns here and there, and converted one 0 to nullptr as a drive-by. Also saves almost 4KiB in text size on optimized GCC 4.9 Linux AMD64 builds. Change-Id: I04b7bfd68dc85c22de247cb65a310e1cbbca1e8c Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll Reviewed-by: Marc Mutz --- src/widgets/dialogs/qfilesystemmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/dialogs/qfilesystemmodel.cpp') diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index bfa40317eb..c72761f2ae 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -374,7 +374,7 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS QModelIndex index = QModelIndex(); // start with "My Computer" #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) if (absolutePath.startsWith(QLatin1String("//"))) { // UNC path - QString host = QLatin1String("\\\\") + pathElements.first(); + QString host = QLatin1String("\\\\") + pathElements.constFirst(); if (absolutePath == QDir::fromNativeSeparators(host)) absolutePath.append(QLatin1Char('/')); if (longPath.endsWith(QLatin1Char('/')) && !absolutePath.endsWith(QLatin1Char('/'))) -- cgit v1.2.3