]> 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)
committerGuillaume Munch <gm@lyx.org>
Tue, 3 May 2016 16:20:58 +0000 (17:20 +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 7a64ba496909c65d5056eb3b8c708cb254b3062f..440422225e4edf74ca1f34caa13f73ba75feec8a 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.