From 764c61a08fb4686b457a61fb49bd802a51d9803a Mon Sep 17 00:00:00 2001 From: Guillaume MM Date: Tue, 25 Jul 2017 00:15:20 +0200 Subject: [PATCH] Fix scrollbar not appearing in new documents unless reloaded (#10729) 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 | 14 +++++++------- src/frontends/qt4/GuiWorkArea_Private.h | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index 7b46eee74f..7ef872ca8b 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -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))); } diff --git a/src/frontends/qt4/GuiWorkArea_Private.h b/src/frontends/qt4/GuiWorkArea_Private.h index a7eea0b1d8..3fb0cd750f 100644 --- a/src/frontends/qt4/GuiWorkArea_Private.h +++ b/src/frontends/qt4/GuiWorkArea_Private.h @@ -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(); -- 2.39.2