]> git.lyx.org Git - lyx.git/commitdiff
Allow for nested setBusy calls.
authorVincent van Ravesteijn <vfr@lyx.org>
Fri, 5 Nov 2010 20:24:58 +0000 (20:24 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Fri, 5 Nov 2010 20:24:58 +0000 (20:24 +0000)
Before, LyX could crash when calling setBusy(false) while LyX is still in a busy state due to a surrounding setBusy(true)/setBusy(false) construction.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36140 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiView.h

index 65a1d3a6f65173bd2c84177a260488fb16682034..c571a373803d14b44e59a9c262d87021161b0d17 100644 (file)
@@ -397,7 +397,7 @@ QSet<Buffer const *> GuiView::GuiViewPrivate::busyBuffers;
 
 
 GuiView::GuiView(int id)
-       : d(*new GuiViewPrivate(this)), id_(id), closing_(false)
+       : d(*new GuiViewPrivate(this)), id_(id), closing_(false), busy_(0)
 {
        // GuiToolbars *must* be initialised before the menu bar.
        normalSizedIcons(); // at least on Mac the default is 32 otherwise, which is huge
@@ -1111,13 +1111,18 @@ bool GuiView::focusNextPrevChild(bool /*next*/)
 
 bool GuiView::busy() const
 {
-       return busy_;
+       return busy_ > 0;
 }
 
 
 void GuiView::setBusy(bool busy)
 {
-       busy_ = busy;
+       bool const busy_before = busy_ > 0;
+       busy ? ++busy_ : --busy_;
+       if ((busy_ > 0) == busy_before)
+               // busy state didn't change
+               return;
+
        if (d.current_work_area_) {
                d.current_work_area_->setUpdatesEnabled(!busy);
                if (busy)
index 4e2a429ac16ce56671ccf6bb3646f004d0844db4..d8fdb3bb25acc96103f3d642ca38602e6876b9cb 100644 (file)
@@ -416,7 +416,10 @@ private:
        /// flag to avoid two concurrent close events.
        bool closing_;
        /// if the view is busy the cursor shouldn't blink for instance.
-       bool busy_;
+       /// This counts the number of times more often we called
+       /// setBusy(true) compared to setBusy(false), so we can nest
+       /// functions that call setBusy;
+       int busy_;
 
 };