From 3dc92d2ede1897b1eadc0e8e1e664e2a9b88017d Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 8 Nov 2023 22:42:33 +0100 Subject: [PATCH] Fix gcc-13 warnings about references to temporaries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ui/clienttoolmodel.cpp:42:21: warning: possibly dangling reference to a temporary [-Wdangling-reference] 42 | const ToolInfo &tool = m_toolManager->tools().at(index.row()); | ^~~~ ui/clienttoolmodel.cpp:42:53: note: the temporary was destroyed at the end of the full expression ‘GammaRay::ClientToolManager::tools() const().QList::at(((qsizetype)(& index)->QModelIndex::row()))’ (cherry picked from commit 4ecfa803c01ed3621a43a276b01480fd523c4134) --- plugins/network/networkinterfacemodel.cpp | 4 ++-- ui/clienttoolmodel.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/network/networkinterfacemodel.cpp b/plugins/network/networkinterfacemodel.cpp index d2d9f712f..79bbce08e 100644 --- a/plugins/network/networkinterfacemodel.cpp +++ b/plugins/network/networkinterfacemodel.cpp @@ -80,8 +80,8 @@ QVariant NetworkInterfaceModel::data(const QModelIndex &index, int role) const return MetaEnum::flagsToString(iface.flags(), interface_flag_table); } } else if (index.column() == 0) { - const auto &iface = m_interfaces.at(index.internalId()); - const auto &addr = iface.addressEntries().at(index.row()); + const auto iface = m_interfaces.at(index.internalId()); + const auto addr = iface.addressEntries().at(index.row()); return QString(addr.ip().toString() + QLatin1Char('/') + addr.netmask().toString()); } } diff --git a/ui/clienttoolmodel.cpp b/ui/clienttoolmodel.cpp index aa3b24ce0..9fe85d8e7 100644 --- a/ui/clienttoolmodel.cpp +++ b/ui/clienttoolmodel.cpp @@ -39,7 +39,7 @@ QVariant ClientToolModel::data(const QModelIndex &index, int role) const if (!index.isValid()) return QVariant(); - const ToolInfo &tool = m_toolManager->tools().at(index.row()); + const ToolInfo tool = m_toolManager->tools().at(index.row()); switch (role) { case Qt::DisplayRole: return tool.name(); @@ -89,7 +89,7 @@ Qt::ItemFlags ClientToolModel::flags(const QModelIndex &index) const if (!index.isValid()) return flags; - const auto &tool = m_toolManager->tools().at(index.row()); + const auto tool = m_toolManager->tools().at(index.row()); if (!tool.isEnabled() || (!tool.remotingSupported() && Endpoint::instance()->isRemoteClient())) flags &= ~(Qt::ItemIsEnabled | Qt::ItemIsSelectable); return flags; -- 2.44.0