forked from qt-creator/qt-creator
QmlProfiler: Fix order of updates to timeline contentX and contentWidth
contentWidth has to be updated before contentX as the WheelArea underneath will clamp its horizontal value to its bounds on change and thus break the update to contentX if contentWidth is growing. As contentX is automatically updated by changes to contentWidth it's generally a good idea to prevent any reactions to that with a recursion guard. When updating contentWidth before contentX this becomes necessary for correct operation. Task-number: QTCREATORBUG-11699 Change-Id: I34fff7a55e93745d658e8cbb5ac3d430a42770e8 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
@@ -79,7 +79,6 @@ Rectangle {
|
||||
|
||||
backgroundMarks.updateMarks(startTime, endTime);
|
||||
view.updateFlickRange(startTime, endTime);
|
||||
flick.setContentWidth();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,15 +287,13 @@ Rectangle {
|
||||
onInteractiveChanged: interactive = stayInteractive
|
||||
onStayInteractiveChanged: interactive = stayInteractive
|
||||
|
||||
function setContentWidth() {
|
||||
onContentXChanged: view.updateZoomControl()
|
||||
onWidthChanged: {
|
||||
var duration = Math.abs(zoomControl.endTime() - zoomControl.startTime());
|
||||
if (duration > 0)
|
||||
contentWidth = qmlProfilerModelProxy.traceDuration() * width / duration;
|
||||
}
|
||||
|
||||
onContentXChanged: view.updateZoomControl()
|
||||
onWidthChanged: setContentWidth()
|
||||
|
||||
// ***** child items
|
||||
TimeMarks {
|
||||
id: backgroundMarks
|
||||
@@ -327,8 +324,15 @@ Rectangle {
|
||||
onEndTimeChanged: requestPaint()
|
||||
onYChanged: requestPaint()
|
||||
onHeightChanged: requestPaint()
|
||||
property bool recursionGuard: false
|
||||
|
||||
function updateZoomControl() {
|
||||
// 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
|
||||
// on external changes to zoomControl.
|
||||
if (recursionGuard)
|
||||
return;
|
||||
|
||||
var newStartTime = Math.round(flick.contentX * (endTime - startTime) / flick.width) +
|
||||
qmlProfilerModelProxy.traceStartTime();
|
||||
if (Math.abs(newStartTime - startTime) > 1) {
|
||||
@@ -341,16 +345,27 @@ Rectangle {
|
||||
}
|
||||
|
||||
function updateFlickRange(start, end) {
|
||||
if (start !== startTime || end !== endTime) {
|
||||
startTime = start;
|
||||
endTime = end;
|
||||
if (!flick.flickingHorizontally) {
|
||||
var newStartX = (startTime - qmlProfilerModelProxy.traceStartTime()) *
|
||||
flick.width / (endTime-startTime);
|
||||
if (isFinite(newStartX) && Math.abs(newStartX - flick.contentX) >= 1)
|
||||
flick.contentX = newStartX;
|
||||
}
|
||||
var duration = end - start;
|
||||
if (recursionGuard || duration <= 0 || (start === startTime && end === endTime))
|
||||
return;
|
||||
|
||||
recursionGuard = true;
|
||||
|
||||
startTime = start;
|
||||
endTime = end;
|
||||
if (!flick.flickingHorizontally) {
|
||||
// This triggers an unwanted automatic change in contentX. We ignore that by
|
||||
// checking recursionGuard in this function and in updateZoomControl.
|
||||
flick.contentWidth = qmlProfilerModelProxy.traceDuration() * flick.width /
|
||||
duration;
|
||||
|
||||
var newStartX = (startTime - qmlProfilerModelProxy.traceStartTime()) *
|
||||
flick.width / duration;
|
||||
|
||||
if (isFinite(newStartX) && Math.abs(newStartX - flick.contentX) >= 1)
|
||||
flick.contentX = newStartX;
|
||||
}
|
||||
recursionGuard = false;
|
||||
}
|
||||
|
||||
onSelectedItemChanged: {
|
||||
|
||||
Reference in New Issue
Block a user