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 <thiago.macieira@intel.com> (cherry picked from commit 18def77d27f88ce26b6af29fe56a80429fed555d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
72baf058be
commit
c19c6aa11e
@ -913,7 +913,8 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
|
||||
if (id == QDBusMetaTypeId::message())
|
||||
break;
|
||||
|
||||
const QVariant &arg = msg.arguments().at(i - 1);
|
||||
const QList<QVariant> args = msg.arguments();
|
||||
const QVariant &arg = args.at(i - 1);
|
||||
if (arg.metaType() == id)
|
||||
// no conversion needed
|
||||
params.append(const_cast<void *>(arg.constData()));
|
||||
|
@ -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;
|
||||
|
@ -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)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user