diff options
author | Ulf Hermann <ulf.hermann@digia.com> | 2014-03-28 16:11:16 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@digia.com> | 2014-04-02 16:47:03 +0200 |
commit | cdfc09f16f9da0b2a13d493593eab795a95d487c (patch) | |
tree | 1b7ac6dcbde319057b7db4f5688de8f99e68c068 | |
parent | be1a94ef1f06780c52221a1c0ed1cf978cf6e1f4 (diff) | |
download | qt-creator-cdfc09f16f9da0b2a13d493593eab795a95d487c.tar.gz |
QmlProfiler: Prevent integer overflows on contentWidth and contentX
Using the extra window the ZoomControl keeps makes it impossible to
increase contentWidth to a point where it overflows. The drawback is that
the position on the scrollbar doesn't reflect the real position of the
visible part of the trace anymore if you zoom in to such a depth.
Task-number: QTCREATORBUG-11879
Change-Id: I6649f3c139f76c242a91d60364a28a4a00c9acee
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
-rw-r--r-- | src/plugins/qmlprofiler/qml/MainView.qml | 41 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qml/SelectionRange.qml | 2 |
2 files changed, 23 insertions, 20 deletions
diff --git a/src/plugins/qmlprofiler/qml/MainView.qml b/src/plugins/qmlprofiler/qml/MainView.qml index c97814e2ed..3455e262a5 100644 --- a/src/plugins/qmlprofiler/qml/MainView.qml +++ b/src/plugins/qmlprofiler/qml/MainView.qml @@ -70,7 +70,12 @@ Rectangle { mainviewTimePerPixel = Math.abs(endTime - startTime) / root.width; backgroundMarks.updateMarks(startTime, endTime); - view.updateFlickRange(startTime, endTime); + view.startTime = startTime; + view.endTime = endTime; + view.updateWindow(); + } + onWindowChanged: { + view.updateWindow(); } } @@ -250,7 +255,7 @@ Rectangle { onWidthChanged: { var duration = Math.abs(zoomControl.endTime() - zoomControl.startTime()); if (duration > 0) - contentWidth = qmlProfilerModelProxy.traceDuration() * width / duration; + contentWidth = zoomControl.windowLength() * width / duration; } // ***** child items @@ -293,33 +298,29 @@ Rectangle { return; var newStartTime = Math.round(flick.contentX * (endTime - startTime) / flick.width) + - qmlProfilerModelProxy.traceStartTime(); + zoomControl.windowStart(); if (Math.abs(newStartTime - startTime) > 1) { var newEndTime = Math.round((flick.contentX + flick.width) * (endTime - startTime) / - flick.width) + - qmlProfilerModelProxy.traceStartTime(); + flick.width) + zoomControl.windowStart(); zoomControl.setRange(newStartTime, newEndTime); } } - function updateFlickRange(start, end) { - var duration = end - start; - if (recursionGuard || duration <= 0 || (start === startTime && end === endTime)) + function updateWindow() { + var duration = zoomControl.duration(); + if (recursionGuard || duration <= 0) return; recursionGuard = true; - startTime = start; - endTime = end; - if (!flick.flickingHorizontally) { + if (!flick.movingHorizontally) { // 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; + flick.contentWidth = zoomControl.windowLength() * flick.width / duration; - var newStartX = (startTime - qmlProfilerModelProxy.traceStartTime()) * - flick.width / duration; + var newStartX = (startTime - zoomControl.windowStart()) * flick.width / + duration; if (isFinite(newStartX) && Math.abs(newStartX - flick.contentX) >= 1) flick.contentX = newStartX; @@ -418,7 +419,9 @@ Rectangle { function updateZoomLevel() { zoomSlider.externalUpdate = true; - zoomSlider.value = Math.pow((view.endTime - view.startTime) / qmlProfilerModelProxy.traceDuration(), 1 / zoomSlider.exponent) * zoomSlider.maximumValue; + zoomSlider.value = Math.pow((view.endTime - view.startTime) / + zoomControl.windowLength(), + 1 / zoomSlider.exponent) * zoomSlider.maximumValue; } @@ -434,7 +437,7 @@ Rectangle { property int minWindowLength: 1e5 // 0.1 ms onValueChanged: { - if (externalUpdate || qmlProfilerModelProxy.traceEndTime() <= qmlProfilerModelProxy.traceStartTime()) { + if (externalUpdate || zoomControl.windowEnd() <= zoomControl.windowStart()) { // Zoom range is independently updated. We shouldn't mess // with it here as otherwise we might introduce rounding // or arithmetic errors. @@ -443,7 +446,7 @@ Rectangle { } var windowLength = Math.max( - Math.pow(value / maximumValue, exponent) * qmlProfilerModelProxy.traceDuration(), + Math.pow(value / maximumValue, exponent) * zoomControl.windowLength(), minWindowLength); var fixedPoint = (view.startTime + view.endTime) / 2; @@ -454,7 +457,7 @@ Rectangle { fixedPoint = newFixedPoint; } - var startTime = Math.max(qmlProfilerModelProxy.traceStartTime(), fixedPoint - windowLength / 2) + var startTime = Math.max(zoomControl.windowStart(), fixedPoint - windowLength / 2) zoomControl.setRange(startTime, startTime + windowLength); } } diff --git a/src/plugins/qmlprofiler/qml/SelectionRange.qml b/src/plugins/qmlprofiler/qml/SelectionRange.qml index b54d0d3eee..7931bdea3a 100644 --- a/src/plugins/qmlprofiler/qml/SelectionRange.qml +++ b/src/plugins/qmlprofiler/qml/SelectionRange.qml @@ -38,7 +38,7 @@ RangeMover { property string endTimeString: detailedPrintTime(startTime+duration) property string durationString: detailedPrintTime(duration) - property double startTime: getLeft() * viewTimePerPixel + qmlProfilerModelProxy.traceStartTime() + property double startTime: getLeft() * viewTimePerPixel + zoomControl.windowStart() property double duration: Math.max(getWidth() * viewTimePerPixel, 500) property double viewTimePerPixel: 1 property double creationReference : 0 |