clang-tidy: clang-analyzer-*

This commit aims to fix all clang-analyzer-* warnings from clang-tidy.
Here is the list of the ones found in project:
    "clang-analyzer-core.uninitialized.UndefReturn",
    "clang-analyzer-deadcode.DeadStores",
    "clang-analyzer-optin.core.EnumCastOutOfRange",
Some exceptions:
  clang-analyzer-cplusplus.NewDeleteLeaks -> may need to disable it as
is a false positive
  clang-analyzer-optin.cplusplus.VirtualCall -> may need to disable it
(or refactor a bunch of code to drop the virtual from those functions)

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2026-02-25 17:15:36 +02:00
parent 323c25d83b
commit 6699d3eca0
No known key found for this signature in database
GPG key ID: 55EF5DA53DB36318
11 changed files with 50 additions and 62 deletions

View file

@ -47,30 +47,31 @@ void ProjectItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o
painter->setOpacity(0.4); // Fade out the entire item
}
// The default icon size will be a square (and height is usually the lower value).
auto icon_width = rect.height(), icon_height = rect.height();
auto icon_width = rect.height();
int icon_x_margin = (rect.height() - icon_width) / 2;
int icon_y_margin = (rect.height() - icon_height) / 2;
if (!opt.icon.isNull()) { // Icon painting
auto icon_height = 0;
{
auto icon_size = opt.decorationSize;
icon_width = icon_size.width();
icon_height = icon_size.height();
icon_y_margin = (rect.height() - icon_height) / 2;
icon_x_margin = icon_y_margin; // use same margins for consistency
icon_x_margin = (rect.height() - icon_height) / 2; // use same margins for consistency
}
// Centralize icon with a margin to separate from the other elements
int x = rect.x() + icon_x_margin;
int y = rect.y() + icon_y_margin;
int y = rect.y() + icon_x_margin;
if (opt.features & QStyleOptionViewItem::HasCheckIndicator)
if (opt.features & QStyleOptionViewItem::HasCheckIndicator) {
rect.translate(icon_x_margin / 2, 0);
}
// Prevent 'scaling null pixmap' warnings
if (icon_width > 0 && icon_height > 0)
if (icon_width > 0 && icon_height > 0) {
opt.icon.paint(painter, x, y, icon_width, icon_height);
}
}
// Change the rect so that funther painting is easier