]> git.lyx.org Git - features.git/commitdiff
Fix "scroll here" feature of scrollbar (#10311)
authorGuillaume Munch <gm@lyx.org>
Fri, 29 Jul 2016 20:27:13 +0000 (21:27 +0100)
committerGuillaume Munch <gm@lyx.org>
Fri, 26 Aug 2016 19:41:08 +0000 (20:41 +0100)
Prevent setRange() from causing a recursive call to scrollTo(). Reduces three
calls of scrollTo() to one call for all scrolling functions of the scroll bar
(e.g. clicking on the arrow, dragging, or clicking somewhere on the scrollbar).

(cherry picked from commit 4d7b912ca1890b5b0b3ed29568b7091a7e7baef0)

src/BufferView.cpp
src/frontends/qt4/GuiWorkArea.cpp

index f304798c82355559ff51b1d7a6018b63a2b96e15..78abc87894827623dd320502528541dd32be68ab 100644 (file)
@@ -565,6 +565,12 @@ void BufferView::updateScrollbar()
                d->scrollbarParameters_.max -= minVisiblePart();
        else
                d->scrollbarParameters_.max -= d->scrollbarParameters_.page_step;
+
+       // 0 must be inside the range as it denotes the current position
+       if (d->scrollbarParameters_.max < 0)
+               d->scrollbarParameters_.max = 0;
+       if (d->scrollbarParameters_.min > 0)
+               d->scrollbarParameters_.min = 0;
 }
 
 
index 7cb732e01a125b8eba8e589f1666b4f1f8321c08..7b8b088504eb64b181782f9cfb12163e2bf15d48 100644 (file)
@@ -675,10 +675,9 @@ void GuiWorkArea::toggleCursor()
 void GuiWorkArea::Private::updateScrollbar()
 {
        ScrollbarParameters const & scroll_ = buffer_view_->scrollbarParameters();
-       // WARNING: don't touch at the scrollbar value like this:
-       //   verticalScrollBar()->setValue(scroll_.position);
-       // because this would cause a recursive signal/slot calling with
-       // GuiWorkArea::scrollTo
+       // Block signals to prevent setRange() and setSliderPosition from causing
+       // recursive calls via the signal valueChanged. (#10311)
+       QSignalBlocker blocker(p->verticalScrollBar());
        p->verticalScrollBar()->setRange(scroll_.min, scroll_.max);
        p->verticalScrollBar()->setPageStep(scroll_.page_step);
        p->verticalScrollBar()->setSingleStep(scroll_.single_step);