summaryrefslogtreecommitdiff
path: root/src/gui/widgets/layout.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-11-14 23:19:49 +0300
committerAndrei Karas <akaras@inbox.ru>2011-11-14 23:19:49 +0300
commitb91146d2cee7397ea952cf7870e04df316d9613e (patch)
tree3101318c8314bf3f2c88da67f62d1c182bc27ddc /src/gui/widgets/layout.cpp
parentbcf7e61d6dd87164d79a211cbda1378e1ddc77bd (diff)
downloadmv-b91146d2cee7397ea952cf7870e04df316d9613e.tar.gz
mv-b91146d2cee7397ea952cf7870e04df316d9613e.tar.bz2
mv-b91146d2cee7397ea952cf7870e04df316d9613e.tar.xz
mv-b91146d2cee7397ea952cf7870e04df316d9613e.zip
Fix incorrect memory access if hiding some gui layout cells.
Diffstat (limited to 'src/gui/widgets/layout.cpp')
-rw-r--r--src/gui/widgets/layout.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp
index 7f2f1f621..f0359062e 100644
--- a/src/gui/widgets/layout.cpp
+++ b/src/gui/widgets/layout.cpp
@@ -222,11 +222,15 @@ LayoutCell &LayoutArray::place(gcn::Widget *widget, int x, int y, int w, int h)
return cell;
}
-void LayoutArray::align(int &pos, int &size, int dim,
- LayoutCell const &cell, int *sizes) const
+void LayoutArray::align(int &pos, int &size, int dim, LayoutCell const &cell,
+ int *sizes, int sizeCount) const
{
int size_max = sizes[0];
- for (int i = 1; i < cell.mExtent[dim]; ++i)
+ int cnt = cell.mExtent[dim];
+ if (sizeCount && cell.mExtent[dim] > sizeCount)
+ cnt = sizeCount;
+
+ for (int i = 1; i < cnt; ++i)
size_max += sizes[i] + mSpacing;
size = std::min<int>(cell.mSize[dim], size_max);
@@ -274,7 +278,8 @@ std::vector<int> LayoutArray::getSizes(int dim, int upp) const
}
}
- if (upp == Layout::AUTO_DEF) return sizes;
+ if (upp == Layout::AUTO_DEF)
+ return sizes;
// Compute the FILL sizes.
int nb = static_cast<int>(sizes.size());
@@ -343,8 +348,10 @@ void LayoutArray::reflow(int nx, int ny, int nw, int nh)
if (cell && cell->mType != LayoutCell::NONE)
{
int dx = x, dy = y, dw = 0, dh = 0;
- align(dx, dw, 0, *cell, &widths[gridX]);
- align(dy, dh, 1, *cell, &heights[gridY]);
+ align(dx, dw, 0, *cell, &widths[gridX],
+ widths.size() - gridX);
+ align(dy, dh, 1, *cell, &heights[gridY],
+ heights.size() - gridY);
cell->reflow(dx, dy, dw, dh);
}
x += widths[gridX] + mSpacing;