Permalink
Browse files

mx-table: Fix an issue with allocation

The else in this was dead code -- if one child was set to expand,
n_expand must be TRUE. Instead, do what the authors intended and
expand all the children if there are no children that explicitly
mark themselves as expanded.

Spotted by Marina Zhurakhinskaya <marinaz@redhat.com>
  • Loading branch information...
magcius committed Dec 12, 2011
1 parent c87bae7 commit b4bd9712517497b3da23d8f10ce4d12ddce153a9
Showing with 10 additions and 24 deletions.
  1. +10 −24 mx/mx-table.c
View
@@ -975,18 +975,11 @@ mx_table_calculate_col_widths (MxTable *table,
for (i = 0; i < priv->n_cols; i++)
{
if (columns[i].expand)
- {
- if (n_expand)
- {
- columns[i].final_size =
- columns[i].pref_size + (extra_width / n_expand);
- }
- else
- {
- columns[i].final_size =
- columns[i].pref_size + (extra_width / priv->n_cols);
- }
- }
+ columns[i].final_size =
+ columns[i].pref_size + (extra_width / n_expand);
+ else if (!n_expand)
+ columns[i].final_size =
+ columns[i].pref_size + (extra_width / priv->n_cols);
else
columns[i].final_size = columns[i].pref_size;
}
@@ -1274,18 +1267,11 @@ mx_table_calculate_row_heights (MxTable *table,
for (i = 0; i < priv->n_rows; i++)
{
if (rows[i].expand)
- {
- if (n_expand)
- {
- rows[i].final_size =
- rows[i].pref_size + (extra_height / n_expand);
- }
- else
- {
- rows[i].final_size =
- rows[i].pref_size + (extra_height / priv->n_rows);
- }
- }
+ rows[i].final_size =
+ rows[i].pref_size + (extra_height / n_expand);
+ else if (!n_expand)
+ rows[i].final_size =
+ rows[i].pref_size + (extra_height / priv->n_rows);
else
rows[i].final_size = rows[i].pref_size;
}

0 comments on commit b4bd971

Please sign in to comment.