QGenericUnixTheme: de-pessimise xdgFileIcon()

Coverity complained about a missing std::move() on the return in L270,
but adding that would, of course, not help, because the QIcon object
being returned is const.

If NRVO would (at least theoretically) kick in, this would be
harmless, but NRVO can't kick in, because it's unknown at the time of
construction whether this will be the object that end up being
returned to the caller, so the compiler will have to copy the object
into the return value when that decision is made (post the isNull()
check).

By not making the object const, we enable it to be moved instead,
which is what Coverity originally wanted us to do.

Amends 46ea82188e3678c5b7a2338d536da6c621822f2f.

Coverity picked this up as a new issue following
53fb13456fffe8bfd192f9197c6d1703854b49a2, so there probably is another
CID for this for the same code in the old location, but my Coverity
search-foo is insufficient to find the corresponding CID, without
undue effort, so I didn't try.

Not picking back, as this is a "low impact" issue, according to
Coverity (and me).

Coverity-Id: 478087
Change-Id: I7f36cdbe83525a23ea0dfa27157091dbdf73a28b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Marc Mutz 2025-03-20 11:36:02 +01:00
parent 8aab205d6d
commit b291047a4d

View File

@ -265,7 +265,7 @@ QIcon QGenericUnixTheme::xdgFileIcon(const QFileInfo &fileInfo)
return QIcon();
const QString &iconName = mimeType.iconName();
if (!iconName.isEmpty()) {
const QIcon icon = QIcon::fromTheme(iconName);
QIcon icon = QIcon::fromTheme(iconName);
if (!icon.isNull())
return icon;
}