From 009dc75fef382738acdf00a2a749293f56a125eb Mon Sep 17 00:00:00 2001 From: Guillaume Munch Date: Sat, 30 Apr 2016 00:25:46 +0100 Subject: [PATCH] TocWidget: Fix perf regression 4d1ad336 fixed #9754 but caused perf issues by cancelling the gains of having a timer (introduced after #7138). This introduces in GuiToc::enableView() a lightweight check of whether the widget should be updated. The logic is inspired from GuiViewSource::enableView(). --- src/frontends/qt4/GuiToc.cpp | 7 +++++-- src/frontends/qt4/TocWidget.cpp | 8 ++++++++ src/frontends/qt4/TocWidget.h | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/frontends/qt4/GuiToc.cpp b/src/frontends/qt4/GuiToc.cpp index f603c56716..7d9b1e5646 100644 --- a/src/frontends/qt4/GuiToc.cpp +++ b/src/frontends/qt4/GuiToc.cpp @@ -66,9 +66,12 @@ void GuiToc::dispatchParams() } -void GuiToc::enableView(bool /*enable*/) +void GuiToc::enableView(bool enable) { - widget_->updateViewForce(); + widget_->checkModelChanged(); + if (!enable) + // In the opposite case, updateView() will be called anyway. + widget_->updateViewForce(); } diff --git a/src/frontends/qt4/TocWidget.cpp b/src/frontends/qt4/TocWidget.cpp index 24bc433776..e3693b7313 100644 --- a/src/frontends/qt4/TocWidget.cpp +++ b/src/frontends/qt4/TocWidget.cpp @@ -452,6 +452,14 @@ void TocWidget::updateViewForce() } +void TocWidget::checkModelChanged() +{ + if (!gui_view_.documentBufferView() || + gui_view_.tocModels().model(current_type_) != tocTV->model()) + updateViewForce(); +} + + void TocWidget::filterContents() { if (!tocTV->model()) diff --git a/src/frontends/qt4/TocWidget.h b/src/frontends/qt4/TocWidget.h index 962c21a238..39a6c2926a 100644 --- a/src/frontends/qt4/TocWidget.h +++ b/src/frontends/qt4/TocWidget.h @@ -42,6 +42,8 @@ public: /// bool getStatus(Cursor & cur, FuncRequest const & fr, FuncStatus & status) const; + // update the view when the model has changed + void checkModelChanged(); public Q_SLOTS: /// Schedule new update of the display unless already scheduled. -- 2.39.5