Author: vfr
Date: Fri Nov 5 21:24:58 2010
New Revision: 36140
URL: http://www.lyx.org/trac/changeset/36140
Log:
Allow for nested setBusy calls.
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.
Modified:
lyx-devel/trunk/src/frontends/qt4/GuiView.cpp
lyx-devel/trunk/src/frontends/qt4/GuiView.h
Modified: lyx-devel/trunk/src/frontends/qt4/GuiView.cpp
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiView.cpp Fri Nov 5 21:13:58
2010 (r36139)
+++ lyx-devel/trunk/src/frontends/qt4/GuiView.cpp Fri Nov 5 21:24:58
2010 (r36140)
@@ -397,7 +397,7 @@
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::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)
Modified: lyx-devel/trunk/src/frontends/qt4/GuiView.h
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiView.h Fri Nov 5 21:13:58 2010
(r36139)
+++ lyx-devel/trunk/src/frontends/qt4/GuiView.h Fri Nov 5 21:24:58 2010
(r36140)
@@ -416,7 +416,10 @@
/// 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_;
};