]> git.lyx.org Git - features.git/commitdiff
TocWidget: Fix perf regression
authorGuillaume Munch <gm@lyx.org>
Fri, 29 Apr 2016 23:25:46 +0000 (00:25 +0100)
committerRichard Heck <rgheck@lyx.org>
Wed, 15 Jun 2016 21:32:53 +0000 (22:32 +0100)
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
src/frontends/qt4/TocWidget.cpp
src/frontends/qt4/TocWidget.h

index f603c567166a2ef4e5ed6ebebaf83ff2c3563fc9..7d9b1e5646b3441090e9e312985bbb1ebd480ae9 100644 (file)
@@ -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();
 }
 
 
index 24bc43377602c1a9685c97ce426dc8b59065e53e..e3693b7313d851e13ebed002666c66bc8c926c4a 100644 (file)
@@ -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())
index 962c21a2387a2d2a63b94ffbf57903e4cc3fbb60..39a6c2926a4888511499ce35651f962f4da62e5f 100644 (file)
@@ -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.