forked from qt-creator/qt-creator
Fix GCC 12 warning about use of uninitialized value
False positive, it couldn't be. `ok` could only become true if
var.toInt() was called, which means some value was assigned to `value`.
But anyway, we can simplify this because QVariant::toInt() returns 0
when it sets ok to false.
classviewutils.cpp:78:50: warning: ‘value’ may be used uninitialized [-Wmaybe-uninitialized]
78 | return SymbolInformation(name, type, iconType);
| ^
Change-Id: Iba16e8ea451b444ab213fffd16f4918c45228f2c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -65,15 +65,7 @@ SymbolInformation symbolInformationFromItem(const QStandardItem *item)
|
|||||||
|
|
||||||
const QString &name = item->data(Constants::SymbolNameRole).toString();
|
const QString &name = item->data(Constants::SymbolNameRole).toString();
|
||||||
const QString &type = item->data(Constants::SymbolTypeRole).toString();
|
const QString &type = item->data(Constants::SymbolTypeRole).toString();
|
||||||
int iconType = 0;
|
int iconType = item->data(Constants::IconTypeRole).toInt();
|
||||||
|
|
||||||
QVariant var = item->data(Constants::IconTypeRole);
|
|
||||||
bool ok = false;
|
|
||||||
int value;
|
|
||||||
if (var.isValid())
|
|
||||||
value = var.toInt(&ok);
|
|
||||||
if (ok)
|
|
||||||
iconType = value;
|
|
||||||
|
|
||||||
return SymbolInformation(name, type, iconType);
|
return SymbolInformation(name, type, iconType);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user