diff options
author | Ville Voutilainen <ville.voutilainen@qt.io> | 2022-11-15 03:28:11 +0200 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2023-01-12 06:23:58 +0000 |
commit | 18def77d27f88ce26b6af29fe56a80429fed555d (patch) | |
tree | 9066c881f0c4fc551d34142ba13714e11e43d60c /src/gui/text/qcssparser.cpp | |
parent | 313720fef09d321194fbd717fc04c14e793cd8b8 (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.
Pick-to: 6.5
Change-Id: If53aa16fcc24586d752ffc76c193c81e43dc9d95
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/gui/text/qcssparser.cpp')
-rw-r--r-- | src/gui/text/qcssparser.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 2f3c04dc54..f79369a36b 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -1439,7 +1439,8 @@ QColor Declaration::colorValue(const QPalette &pal) const return pal.color((QPalette::ColorRole)(d->parsed.toInt())); case qMetaTypeId<QList<QVariant>>(): if (d->parsed.toList().size() == 1) { - const auto &value = d->parsed.toList().at(0); + auto parsedList = d->parsed.toList(); + const auto &value = parsedList.at(0); return qvariant_cast<QColor>(value); } break; |