23033: Parts are displayed at incorrect zoom level when the Navigator is open #25886
+1
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves: #23033
KEY POINTS:
Overview:
When the Navigator is open, it creates a
NotationNavigator
instance which inherits fromAbstractNotationPaintView
.For the actual notation an instance of
NotationPaintView
is created which also inherits fromAbstractNotationPaintView
.Both of these listen for current notation changes in
AbstractNotationPaintView::onNotationSetup()
(line 622) and callonCurrentNotationChanged()
(line 623).AbstractNotationPaintView::onCurrentNotationChanged()
callsonLoadNotation
(line 226).onLoadNotation
is supposed to callm_inputController->initZoom();
(line 232) where the zoom on the notation should be set (if not previously set) following these calls:NotationViewInputController::initZoom()
NotationViewInputController::setZoom
/doZoomToPageWidth
/doZoomToWholePage
etc.AbstractNotationPaintView::setScaling
AbstractNotationPaintView::scale
AbstractNotationPaintView::onMatrixChanged
for theNotationNavigator
instance orNotationPaintView::onMatrixChanged
for theNotationPaintView
instance (an override).The problem is in that:
The zoom is actually set in
NotationPaintView::onMatrixChanged
when it callsnotation()->viewState()->setMatrix
(line 62).The above steps execute first for the
NotationNavigator
instance since it registers to listen foronCurrentNotationChanged
notification before theNotationPaintView
instance registers itself.When the steps execute for the
NotationNavigator
instance, the zoom won't be set butNotationViewInputController::initZoom()
will setisMatrixInited
on the notation's viewstate totrue
(line 171).When the steps execute the second time for the
NotationPaintView
instance,onLoadNotation
does not callm_inputController->initZoom()
(line 232) because the if condition returnsfalse
due toisMatrixInited()
being true for the notation.The zoom of the notation remains unset and defaults to 0.
When the Navigator is not visible, the
NotationNavigator
instance is not created and does not interfere.Further observations:
When the Navigator is active the two
AbstractNotationPaintView
descendants share the same notation. As a result the code inAbstractNotationPaintView::onLoadNotation
that operates on the notation executes twice, e.g. event listeners are bound twice and the handlers are executed twice. Therefore those pieces of code should probably be moved elsewhere (not as part of this issue though).