Commit b3348dae authored by Ulf Hermann's avatar Ulf Hermann

QmlProfiler: Make sure TimelineRenderer is using the right x and width

If we use different x and width parameters in JavaScript and C++ we
introduce numerical instability which leads to visual glitches.

Change-Id: I352f3e8365ca52d135230343c2f034332ec71323
Task-number: QTCREATORBUG-12648
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent 141d0d90
...@@ -273,7 +273,6 @@ Rectangle { ...@@ -273,7 +273,6 @@ Rectangle {
onInteractiveChanged: interactive = stayInteractive onInteractiveChanged: interactive = stayInteractive
onStayInteractiveChanged: interactive = stayInteractive onStayInteractiveChanged: interactive = stayInteractive
onContentXChanged: view.updateZoomControl()
onWidthChanged: { onWidthChanged: {
var duration = Math.abs(zoomControl.endTime() - zoomControl.startTime()); var duration = Math.abs(zoomControl.endTime() - zoomControl.startTime());
if (duration > 0) if (duration > 0)
...@@ -312,19 +311,20 @@ Rectangle { ...@@ -312,19 +311,20 @@ Rectangle {
onHeightChanged: requestPaint() onHeightChanged: requestPaint()
property bool recursionGuard: false property bool recursionGuard: false
function updateZoomControl() { property int intX: x
property int intWidth: width
onIntXChanged: {
// Don't updateZoomControl if we're just updating the flick range, _from_ // Don't updateZoomControl if we're just updating the flick range, _from_
// zoomControl. The other way round is OK. We _want_ the flick range to be updated // zoomControl. The other way round is OK. We _want_ the flick range to be updated
// on external changes to zoomControl. // on external changes to zoomControl.
if (recursionGuard) if (recursionGuard)
return; return;
var newStartTime = Math.round(flick.contentX * (endTime - startTime) / flick.width) + var newStartTime = intX * (endTime - startTime) / intWidth +
zoomControl.windowStart(); zoomControl.windowStart();
if (Math.abs(newStartTime - startTime) > 1) { if (Math.abs(newStartTime - startTime) >= 1) {
var newEndTime = Math.round((flick.contentX + flick.width) * var newEndTime = (intX + intWidth) * (endTime - startTime) / intWidth +
(endTime - startTime) / zoomControl.windowStart();
flick.width) + zoomControl.windowStart();
zoomControl.setRange(newStartTime, newEndTime); zoomControl.setRange(newStartTime, newEndTime);
} }
} }
...@@ -339,12 +339,12 @@ Rectangle { ...@@ -339,12 +339,12 @@ Rectangle {
if (!flick.movingHorizontally) { if (!flick.movingHorizontally) {
// This triggers an unwanted automatic change in contentX. We ignore that by // This triggers an unwanted automatic change in contentX. We ignore that by
// checking recursionGuard in this function and in updateZoomControl. // checking recursionGuard in this function and in updateZoomControl.
flick.contentWidth = zoomControl.windowLength() * flick.width / duration; flick.contentWidth = zoomControl.windowLength() * intWidth / duration;
var newStartX = (startTime - zoomControl.windowStart()) * flick.width / var newStartX = (startTime - zoomControl.windowStart()) * intWidth /
duration; duration;
if (isFinite(newStartX) && Math.abs(newStartX - flick.contentX) >= 1) if (isFinite(newStartX) && Math.abs(newStartX - intX) >= 1)
flick.contentX = newStartX; flick.contentX = newStartX;
} }
recursionGuard = false; recursionGuard = false;
...@@ -379,8 +379,8 @@ Rectangle { ...@@ -379,8 +379,8 @@ Rectangle {
} }
// hack to pass mouse events to the other mousearea if enabled // hack to pass mouse events to the other mousearea if enabled
startDragArea: selectionRange.ready ? selectionRange.getLeft() : -flick.contentX startDragArea: selectionRange.ready ? selectionRange.getLeft() : -x
endDragArea: selectionRange.ready ? selectionRange.getRight() : -flick.contentX-1 endDragArea: selectionRange.ready ? selectionRange.getRight() : -x - 1
} }
MouseArea { MouseArea {
id: selectionRangeControl id: selectionRangeControl
......
Markdown is supported
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