Fix some static analysis warnings

This commit is contained in:
Megamouse 2024-11-27 20:38:07 +01:00
parent 5491fbee5b
commit 657ab4261c
4 changed files with 19 additions and 21 deletions

View file

@ -79,10 +79,13 @@ flow_layout::~flow_layout()
void flow_layout::clear()
{
while (QLayoutItem* item = takeAt(0))
for (QLayoutItem* item : m_item_list)
{
delete item->widget();
delete item;
if (item)
{
delete item->widget();
delete item;
}
}
m_item_list.clear();
m_positions.clear();
@ -185,8 +188,8 @@ int flow_layout::doLayout(const QRect& rect, bool testOnly) const
int x = effectiveRect.x();
int y = effectiveRect.y();
int lineHeight = 0;
int rows = 0;
int cols = 0;
int row_count = 0;
int col_count = 0;
if (m_dynamic_spacing)
{
@ -259,8 +262,8 @@ int flow_layout::doLayout(const QRect& rect, bool testOnly) const
pos.row = row;
pos.col = col++;
rows = std::max(rows, pos.row + 1);
cols = std::max(cols, pos.col + 1);
row_count = std::max(row_count, pos.row + 1);
col_count = std::max(col_count, pos.col + 1);
if (!testOnly)
item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));
@ -269,8 +272,8 @@ int flow_layout::doLayout(const QRect& rect, bool testOnly) const
lineHeight = qMax(lineHeight, item->sizeHint().height());
}
m_rows = rows;
m_cols = cols;
m_rows = row_count;
m_cols = col_count;
return y + lineHeight - rect.y() + bottom;
}