From 0599cb7366efa3404acd3224774895f54ce0bb69 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 30 Oct 2013 13:49:01 +0100 Subject: [PATCH] QmlProfiler: Avoid drawing outside of widget Avoid rendering outside of the canvas by forcing the windows size onto the scene, and also removing the related candidateSize logic. In the QtQUick1 based profiler one could scroll the canvas also vertically, but that doesn't work any more. This is a hot fix to work around the problem, we can hopefully bring back the full solution later ... Change-Id: Ibd3d54f6b98c3764e104116d395a77b880d88bcb Reviewed-by: Ulf Hermann Reviewed-by: Kai Koehne --- src/plugins/qmlprofiler/qml/MainView.qml | 8 +++----- src/plugins/qmlprofiler/qml/RangeDetails.qml | 10 +++++----- src/plugins/qmlprofiler/qml/SelectionRange.qml | 4 ++-- src/plugins/qmlprofiler/qml/SelectionRangeDetails.qml | 10 +++++----- src/plugins/qmlprofiler/qmlprofilertraceview.cpp | 6 ++---- 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/plugins/qmlprofiler/qml/MainView.qml b/src/plugins/qmlprofiler/qml/MainView.qml index 82a77d6bcc5..10b190cea95 100644 --- a/src/plugins/qmlprofiler/qml/MainView.qml +++ b/src/plugins/qmlprofiler/qml/MainView.qml @@ -35,9 +35,7 @@ Rectangle { // ***** properties - property int candidateHeight: 0 property int scrollY: 0 - height: Math.max( candidateHeight, labels.height + 2 ) property int singleRowHeight: 30 @@ -464,9 +462,9 @@ Rectangle { root.updateVerticalScroll(itemY); } else if (itemY + root.singleRowHeight > - root.scrollY + root.candidateHeight) { + root.scrollY + root.height) { root.updateVerticalScroll(itemY + root.singleRowHeight - - root.candidateHeight); + root.height); } } else { @@ -584,7 +582,7 @@ Rectangle { } Rectangle { - y: root.scrollY + root.candidateHeight - height + y: root.scrollY + root.height - height height: 6 width: root.width x: 0 diff --git a/src/plugins/qmlprofiler/qml/RangeDetails.qml b/src/plugins/qmlprofiler/qml/RangeDetails.qml index 2fe6e398f29..2d379737538 100644 --- a/src/plugins/qmlprofiler/qml/RangeDetails.qml +++ b/src/plugins/qmlprofiler/qml/RangeDetails.qml @@ -62,7 +62,7 @@ Item { Connections { target: root onWidthChanged: fitInView(); - onCandidateHeightChanged: fitInView(); + onHeightChanged: fitInView(); } //property int eventInfo @@ -97,15 +97,15 @@ Item { function fitInView() { // don't reposition if it does not fit - if (root.width < width || root.candidateHeight < height) + if (root.width < width || root.height < height) return; if (x + width > root.width) x = root.width - width; if (x < 0) x = 0; - if (y - yoffset + height > root.candidateHeight) - y = root.candidateHeight - height + yoffset; + if (y - yoffset + height > root.height) + y = root.height - height + yoffset; if (y < yoffset) y = yoffset; } @@ -193,7 +193,7 @@ Item { drag.minimumX: 0 drag.maximumX: root.width - parent.width drag.minimumY: yoffset - drag.maximumY: root.candidateHeight - parent.height + yoffset + drag.maximumY: root.height - parent.height + yoffset onClicked: { root.gotoSourceLocation(file, line, column); root.recenterOnItem(view.selectedModel, view.selectedItem); diff --git a/src/plugins/qmlprofiler/qml/SelectionRange.qml b/src/plugins/qmlprofiler/qml/SelectionRange.qml index 1e12458c7ef..96558142555 100644 --- a/src/plugins/qmlprofiler/qml/SelectionRange.qml +++ b/src/plugins/qmlprofiler/qml/SelectionRange.qml @@ -184,7 +184,7 @@ Rectangle { width: 4 height: 63 fillMode: Image.Tile - y: root.scrollY + root.candidateHeight / 2 - 32 + y: root.scrollY + root.height / 2 - 32 } } @@ -252,7 +252,7 @@ Rectangle { width: 4 height: 63 fillMode: Image.Tile - y: root.scrollY + root.candidateHeight / 2 - 32 + y: root.scrollY + root.height / 2 - 32 } } diff --git a/src/plugins/qmlprofiler/qml/SelectionRangeDetails.qml b/src/plugins/qmlprofiler/qml/SelectionRangeDetails.qml index c7e281bf085..d1bd5f6645d 100644 --- a/src/plugins/qmlprofiler/qml/SelectionRangeDetails.qml +++ b/src/plugins/qmlprofiler/qml/SelectionRangeDetails.qml @@ -57,20 +57,20 @@ Item { Connections { target: root onWidthChanged: fitInView(); - onCandidateHeightChanged: fitInView(); + onHeightChanged: fitInView(); } function fitInView() { // don't reposition if it does not fit - if (root.width < width || root.candidateHeight < height) + if (root.width < width || root.height < height) return; if (x + width > root.width) x = root.width - width; if (x < 0) x = 0; - if (y + height - yoffset > root.candidateHeight) - y = root.candidateHeight - height + yoffset; + if (y + height - yoffset > root.height) + y = root.height - height + yoffset; if (y < yoffset) y = yoffset; } @@ -162,7 +162,7 @@ Item { drag.minimumX: 0 drag.maximumX: root.width - parent.width drag.minimumY: yoffset - drag.maximumY: root.candidateHeight - parent.height + yoffset + drag.maximumY: root.height - parent.height + yoffset onClicked: { if ((selectionRange.x < flick.contentX) ^ (selectionRange.x+selectionRange.width > flick.contentX + flick.width)) { root.recenter(selectionRange.startTime + selectionRange.duration/2); diff --git a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp index 76874e92729..454b714cb15 100644 --- a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp @@ -153,7 +153,7 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerT groupLayout->setSpacing(0); d->m_mainView = new ScrollableQuickView(); - d->m_mainView->setResizeMode(QQuickView::SizeViewToRootObject); + d->m_mainView->setResizeMode(QQuickView::SizeRootObjectToView); QWidget *mainViewContainer = QWidget::createWindowContainer(d->m_mainView); MouseWheelResizer *resizer = new MouseWheelResizer(this); @@ -229,10 +229,8 @@ void QmlProfilerTraceView::reset() d->m_overview->setSource(QUrl(QLatin1String("qrc:/qmlprofiler/Overview.qml"))); d->m_mainView->setSource(QUrl(QLatin1String("qrc:/qmlprofiler/MainView.qml"))); - QQuickItem *rootObject = d->m_mainView->rootObject(); - rootObject->setProperty("width", QVariant(width())); - rootObject->setProperty("candidateHeight", QVariant(height() - d->m_timebar->height() - d->m_overview->height())); + QQuickItem *rootObject = d->m_mainView->rootObject(); connect(rootObject, SIGNAL(updateCursorPosition()), this, SLOT(updateCursorPosition())); connect(rootObject, SIGNAL(updateRangeButton()), this, SLOT(updateRangeButton())); connect(rootObject, SIGNAL(updateLockButton()), this, SLOT(updateLockButton()));