[Scummvm-git-logs] scummvm master -> 287a4a12e22b55487a99d489d3819233ae50bbc4
bgK
bastien.bouclet at gmail.com
Sat Oct 19 10:53:26 CEST 2019
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
287a4a12e2 GUI: Fix crash when opening the save name dialog
Commit: 287a4a12e22b55487a99d489d3819233ae50bbc4
https://github.com/scummvm/scummvm/commit/287a4a12e22b55487a99d489d3819233ae50bbc4
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2019-10-19T10:50:56+02:00
Commit Message:
GUI: Fix crash when opening the save name dialog
The changes in 1dce33dd9f909b09a73902b3939b61a81a149b7a introduced a
case where the width of widgets would not be set. This commit reverts
the offending changes and introduces a different fix for the original
issue.
Only recompute the width/height of a stack if it is not explicitly set.
Fixes #11214.
Changed paths:
gui/ThemeLayout.cpp
diff --git a/gui/ThemeLayout.cpp b/gui/ThemeLayout.cpp
index 4e3499b..a05ac87 100644
--- a/gui/ThemeLayout.cpp
+++ b/gui/ThemeLayout.cpp
@@ -181,6 +181,7 @@ void ThemeLayoutStacked::reflowLayoutVertical() {
int curX, curY;
int resize[8];
int rescount = 0;
+ bool fixedWidth = _w != -1;
curX = _padding.left;
curY = _padding.top;
@@ -202,11 +203,20 @@ void ThemeLayoutStacked::reflowLayoutVertical() {
_children[i]->offsetY(curY);
+ // Center child if it this has been requested *and* the space permits it.
+ if (_centered && _children[i]->getWidth() < (_w - _padding.left - _padding.right) && _w != -1) {
+ _children[i]->offsetX((_w >> 1) - (_children[i]->getWidth() >> 1));
+ } else
+ _children[i]->offsetX(curX);
+
// Advance the vertical offset by the height of the newest item, plus
// the item spacing value.
curY += _children[i]->getHeight() + _spacing;
- // Update the height of this stack layout
+ // Update width and height of this stack layout
+ if (!fixedWidth) {
+ _w = MAX(_w, (int16)(_children[i]->getWidth() + _padding.left + _padding.right));
+ }
_h += _children[i]->getHeight() + _spacing;
}
@@ -231,27 +241,13 @@ void ThemeLayoutStacked::reflowLayoutVertical() {
_children[j]->offsetY(newh);
}
}
-
- // Set stack width from its children if it was not set by its parent
- if (_w == -1) {
- for (uint i = 0; i < _children.size(); ++i) {
- _w = MAX(_w, (int16)(_children[i]->getWidth() + _padding.left + _padding.right));
- }
- }
-
- for (uint i = 0; i < _children.size(); ++i) {
- // Center child if it this has been requested *and* the space permits it.
- if (_centered && _children[i]->getWidth() < (_w - _padding.left - _padding.right) && _w != -1) {
- _children[i]->offsetX((_w >> 1) - (_children[i]->getWidth() >> 1));
- } else
- _children[i]->offsetX(curX);
- }
}
void ThemeLayoutStacked::reflowLayoutHorizontal() {
int curX, curY;
int resize[8];
int rescount = 0;
+ bool fixedHeight = _h != -1;
curX = _padding.left;
curY = _padding.top;
@@ -273,12 +269,21 @@ void ThemeLayoutStacked::reflowLayoutHorizontal() {
_children[i]->offsetX(curX);
+ // Center child if it this has been requested *and* the space permits it.
+ if (_centered && _children[i]->getHeight() < (_h - _padding.top - _padding.bottom) && _h != -1)
+ _children[i]->offsetY((_h >> 1) - (_children[i]->getHeight() >> 1));
+ else
+ _children[i]->offsetY(curY);
+
// Advance the horizontal offset by the width of the newest item, plus
// the item spacing value.
curX += (_children[i]->getWidth() + _spacing);
- // Update the width of this stack layout
+ // Update width and height of this stack layout
_w += _children[i]->getWidth() + _spacing;
+ if (!fixedHeight) {
+ _h = MAX(_h, (int16)(_children[i]->getHeight() + _padding.top + _padding.bottom));
+ }
}
// If there are any children at all, then we added the spacing value once
@@ -302,21 +307,6 @@ void ThemeLayoutStacked::reflowLayoutHorizontal() {
_children[j]->offsetX(neww);
}
}
-
- // Set stack height from its children if it was not set by its parent
- if (_h == -1) {
- for (uint i = 0; i < _children.size(); ++i) {
- _h = MAX(_h, (int16)(_children[i]->getHeight() + _padding.top + _padding.bottom));
- }
- }
-
- for (uint i = 0; i < _children.size(); ++i) {
- // Center child if it this has been requested *and* the space permits it.
- if (_centered && _children[i]->getHeight() < (_h - _padding.top - _padding.bottom) && _h != -1)
- _children[i]->offsetY((_h >> 1) - (_children[i]->getHeight() >> 1));
- else
- _children[i]->offsetY(curY);
- }
}
} // End of namespace GUI
More information about the Scummvm-git-logs
mailing list