diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-05-27 10:37:35 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-05-27 12:31:23 +0000 |
commit | fdf8a963f556a4996ea09eda35fec191baff66b5 (patch) | |
tree | d4d03fa3d425a3202a2bfb1f0a982799801a9140 | |
parent | 66129f8790c76165faf76eb8736c76eae2afafb8 (diff) |
Material: prevent ElevationEffect access out of bounds
The elevation shadows are defined in a JS array for elevations between
0-24. Clamp the user-defined elevation number to prevent access out of
bounds:
Button {
Material.elevation: 100 // ElevationEffect.qml: TypeError:
// Cannot read property '0' of undefined
}
Change-Id: I6b5a915042081be54101fd700b52c8eea96aa05d
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | src/imports/controls/material/ElevationEffect.qml | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/imports/controls/material/ElevationEffect.qml b/src/imports/controls/material/ElevationEffect.qml index 93a32f83..4ee4369c 100644 --- a/src/imports/controls/material/ElevationEffect.qml +++ b/src/imports/controls/material/ElevationEffect.qml @@ -215,7 +215,7 @@ Item { The current shadow based on the elevation. */ - readonly property var _shadow: _shadows[elevation] + readonly property var _shadow: _shadows[Math.max(0, Math.min(elevation, _shadows.length - 1))] // Nest the shadows and source view in two items rendered as a layer // so the shadow is not clipped by the bounds of the source view |