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
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)
/// 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_;
};