I have a patch for
http://www.lyx.org/trac/ticket/10311
which I attach on this email for convenience.

It fixes the bug for me, but I don't actually understand what's going
on. It is a simple patch (just a reordering), but since I don't
understand exactly why it works I would like to either commit it now to
master early in the release process, or not commit it at all (e.g. if it
looks suspicious to someone).

The bug it fixes is minor, but it potentially improves performance
(reduces three calls of a function to two calls) for all scrolling of
the scroll bar (e.g. clicking on the arrow, dragging, or left-clicking
somewhere on the scrollbar).

Any comments?

Scott
From a98749efc8a73b02df316840d3da9061f027f396 Mon Sep 17 00:00:00 2001
From: Scott Kostyshak <skost...@lyx.org>
Date: Tue, 26 Jul 2016 20:10:13 -0400
Subject: [PATCH] Fix "scroll here" feature of scrollbar

Note that right-clicking on the scroll bar and clicking on "scroll
here" is equivalent to middle-clicking. Note also that "scroll
here" is a Qt feature, not a LyX implementation.

To reproduce, open the math manual and middle-click on say 3/5 of
the way on the scroll bar, the scroll bar jumps to the end. If you
middle-click in the same place (a second time) it then goes to the
expected position. Notice the same issue if you now click on 2/5 of
the way (the scroll bar jumps to the beginning).

There are three calls to GuiWorkArea::scrollTo() when executing a
"scroll here". From what I understand, the first call does the real
scrolling and the third call is with value 0 which I think is just a
way of resetting the scrollbar to the new location. However, the
second call seems to be not only unnecessary but causes the problem
in this issue. A left click on the scrollbar (on the arrow or scroll
area) only requires two calls to GuiWorkArea::scrollTo().

I think this extra call to scrollTo() happens because the "scroll
here" or middle-click gives a signal that is connected to a slot
that calls scrollTo().

This commit fixes the problem for me and the number of calls to
scrollTo() goes from 3 to 2.
---
 src/frontends/qt4/GuiWorkArea.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/frontends/qt4/GuiWorkArea.cpp 
b/src/frontends/qt4/GuiWorkArea.cpp
index d8675be..ab924fc 100644
--- a/src/frontends/qt4/GuiWorkArea.cpp
+++ b/src/frontends/qt4/GuiWorkArea.cpp
@@ -675,10 +675,12 @@ void GuiWorkArea::Private::updateScrollbar()
        //   verticalScrollBar()->setValue(scroll_.position);
        // because this would cause a recursive signal/slot calling with
        // GuiWorkArea::scrollTo
-       p->verticalScrollBar()->setRange(scroll_.min, scroll_.max);
+       //
+       // setRange is called last. See #10311.
        p->verticalScrollBar()->setPageStep(scroll_.page_step);
        p->verticalScrollBar()->setSingleStep(scroll_.single_step);
        p->verticalScrollBar()->setSliderPosition(0);
+       p->verticalScrollBar()->setRange(scroll_.min, scroll_.max);
 }
 
 
-- 
2.7.4

Attachment: signature.asc
Description: PGP signature

Reply via email to