Commit b3d081d1 authored by Bart De Vries's avatar Bart De Vries Committed by Nate Graham
Browse files

Rescale internal Slider values to avoid integer overflow

The original implementation used the raw duration and position as
reported by qmultimedia, which are in milliseconds. This, combined with
the actual Slider implementation in qqc2-desktop-style caused
value/duration to overflow at about 3 minutes and 30 seconds.
The adapted implementation uses seconds for the internal Slider values.

CCBUG: 455339


(cherry picked from commit 98227f05)
parent a7607074
Pipeline #194247 passed with stage
in 3 minutes and 58 seconds
......@@ -24,12 +24,12 @@ RowLayout {
onPositionChanged: {
if (!musicProgress.seekStarted) {
musicProgress.value = position
musicProgress.value = position / 1000
}
}
onDurationChanged: {
musicProgress.to = durationSlider.duration
musicProgress.value = Qt.binding(function() { return durationSlider.position })
musicProgress.to = durationSlider.duration / 1000
musicProgress.value = Qt.binding(() => durationSlider.position / 1000)
}
spacing: 0
......@@ -70,15 +70,15 @@ RowLayout {
Layout.rightMargin: !LayoutMirroring.enabled ? Kirigami.Units.largeSpacing : 0
Layout.leftMargin: LayoutMirroring.enabled ? Kirigami.Units.largeSpacing : 0
// from, to and value of Slider are rescaled to seconds to avoid integer overflow issues
from: 0
to: durationSlider.duration
to: durationSlider.duration / 1000
enabled: durationSlider.seekable && durationSlider.playEnabled
live: true
onMoved: {
durationSlider.seek(value)
durationSlider.seek(value * 1000)
}
MouseArea {
......@@ -86,9 +86,9 @@ RowLayout {
acceptedButtons: Qt.NoButton
onWheel: {
if (wheel.angleDelta.y > 0) {
durationSlider.seek(musicProgress.value + 10000)
durationSlider.seek((musicProgress.value + 10) * 1000)
} else {
durationSlider.seek(musicProgress.value - 10000)
durationSlider.seek((musicProgress.value - 10) * 1000)
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment