summaryrefslogtreecommitdiffstats
path: root/src/tools/qtpaths/qtpaths.cpp
diff options
context:
space:
mode:
authorVille Voutilainen <[email protected]>2022-11-15 03:28:11 +0200
committerQt Cherry-pick Bot <[email protected]>2023-01-12 06:24:08 +0000
commitc19c6aa11e3d35bdd2741e9f31725c495be431aa (patch)
tree0bbd690dcd63c8226e077f44f33afcc5f8ed9a1a /src/tools/qtpaths/qtpaths.cpp
parent72baf058bea2d0575041324073fd773a396723bc (diff)
Fix dangling references
These were found with the help of -Wdangling-reference, which is new in GCC 13. The one in qtpaths.cpp is a false positive: parseLocationOrError() returns a reference, so there's nothing for the full expression to destroy. Moreover, it returns a reference to a static object, so there's no destruction inside the function either. The other two aren't, but are also harmless. QDBusMessage::arguments() and QVariant::toList() return a stored QVariantList by value, so QList's COW mechanism means at() returns a reference that will not be destroyed. However, the compiler has no way of knowing that. And since it depends on the implementation details, change the code to not depend on that. Change-Id: If53aa16fcc24586d752ffc76c193c81e43dc9d95 Reviewed-by: Thiago Macieira <[email protected]> (cherry picked from commit 18def77d27f88ce26b6af29fe56a80429fed555d) Reviewed-by: Qt Cherry-pick Bot <[email protected]>
Diffstat (limited to 'src/tools/qtpaths/qtpaths.cpp')
-rw-r--r--src/tools/qtpaths/qtpaths.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/tools/qtpaths/qtpaths.cpp b/src/tools/qtpaths/qtpaths.cpp
index b4e2d749aa3..fa29381d789 100644
--- a/src/tools/qtpaths/qtpaths.cpp
+++ b/src/tools/qtpaths/qtpaths.cpp
@@ -252,6 +252,10 @@ int main(int argc, char **argv)
results << typesList.join('\n');
}
+ QT_WARNING_PUSH
+#if defined(Q_CC_GNU_ONLY) && Q_CC_GNU >= 1300 && Q_CC_GNU < 1400
+ QT_WARNING_DISABLE_GCC("-Wdangling-reference")
+#endif
if (parser.isSet(display)) {
const StringEnum &location = parseLocationOrError(parser.value(display));
QString text = QStandardPaths::displayName(location.enumvalue);
@@ -303,6 +307,7 @@ int main(int argc, char **argv)
QStringList paths = QStandardPaths::locateAll(location.enumvalue, searchitem, QStandardPaths::LocateFile);
results << location.mapName(paths.join(pathsep));
}
+ QT_WARNING_POP
#if !QT_CONFIG(settings)
if (parser.isSet(query) || parser.isSet(qtconf) || parser.isSet(queryformat)) {