diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index c78a068978..c22fb322c5 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -538,8 +538,9 @@ void GuiView::closeEvent(QCloseEvent * close_event) GuiWorkArea * active_wa = currentMainWorkArea(); setCurrentWorkArea(active_wa); - int splitter_count = d.splitter_->count(); - for (; splitter_count; --splitter_count) { + // We have to call count() each time, because it can happen that + // more than one splitter will disappear in one iteration (bug 5998). + for (; d.splitter_->count(); ) { TabWorkArea * twa = d.tabWorkArea(0); int twa_count = twa->count();