]> git.lyx.org Git - features.git/commitdiff
Fix scrollbar not appearing in new documents unless reloaded (#10729)
authorGuillaume MM <gm@lyx.org>
Mon, 24 Jul 2017 22:15:20 +0000 (00:15 +0200)
committerGuillaume MM <gm@lyx.org>
Mon, 24 Jul 2017 22:33:48 +0000 (00:33 +0200)
QSignalBlocker in updateScrollbar is too strong and prevents the scroll bar from
communicating with its scroll area. The only solution to block signals between
specifically between two objects is to disconnect. This makes sense in this
case, by making updateScrollbar responsible for managing the connection in the
first place.

src/frontends/qt4/GuiWorkArea.cpp
src/frontends/qt4/GuiWorkArea_Private.h

index 7b46eee74f9ea40fa93dd7dd8c135699a593af1d..7ef872ca8bdeed31439702bd3d0f34dfe25cbd2a 100644 (file)
@@ -325,10 +325,6 @@ void GuiWorkArea::init()
                        generateSyntheticMouseEvent();
                });
 
-       // Initialize the vertical Scroll Bar
-       QObject::connect(verticalScrollBar(), SIGNAL(valueChanged(int)),
-               this, SLOT(scrollTo(int)));
-
        LYXERR(Debug::GUI, "viewport width: " << viewport()->width()
                << "  viewport height: " << viewport()->height());
 
@@ -675,14 +671,18 @@ void GuiWorkArea::toggleCursor()
 
 void GuiWorkArea::Private::updateScrollbar()
 {
+       // Prevent setRange() and setSliderPosition from causing recursive calls via
+       // the signal valueChanged. (#10311)
+       QObject::disconnect(p->verticalScrollBar(), SIGNAL(valueChanged(int)),
+                           p, SLOT(scrollTo(int)));
        ScrollbarParameters const & scroll_ = buffer_view_->scrollbarParameters();
-       // 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);
        p->verticalScrollBar()->setSliderPosition(0);
+       // Connect to the vertical scroll bar
+       QObject::connect(p->verticalScrollBar(), SIGNAL(valueChanged(int)),
+                        p, SLOT(scrollTo(int)));
 }
 
 
index a7eea0b1d85f150edda3578ad16cc23383060abd..3fb0cd750fe2f88bf9d0d31018e6c69e944dc13e 100644 (file)
@@ -111,7 +111,8 @@ struct GuiWorkArea::Private
        void hideCursor();
        /// show the cursor if it is not visible
        void showCursor();
-       ///
+       /// Set the range and value of the scrollbar and connect to its valueChanged
+       /// signal.
        void updateScrollbar();
        /// Change the cursor when the mouse hovers over a clickable inset
        void updateCursorShape();