branch: Fix bug #5001: Tab order not preserved when starting lyx.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@29533 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2009-05-04 19:20:20 +00:00
parent ee2bad7dc7
commit bcf361f389

View File

@ -526,58 +526,68 @@ void GuiView::closeEvent(QCloseEvent * close_event)
// e.g. when clicking the close button on a background window.
setFocus();
while (Buffer * b = buffer()) {
if (b->parent()) {
// This is a child document, just close the tab
// after saving but keep the file loaded.
if (!closeBuffer(*b, true)) {
int splitter_count = d.splitter_->count();
for (; splitter_count > 0; --splitter_count) {
TabWorkArea * twa = d.tabWorkArea(0);
int twa_count = twa->count();
for (; twa_count > 0; --twa_count) {
twa->setCurrentIndex(0);
GuiWorkArea * wa = twa->currentWorkArea();
Buffer * b = &wa->bufferView().buffer();
if (b->parent()) {
// This is a child document, just close the tab
// after saving but keep the file loaded.
if (!closeBuffer(*b, true)) {
closing_ = false;
close_event->ignore();
return;
}
continue;
}
vector<Buffer *> clist = b->getChildren();
for (vector<Buffer *>::const_iterator it = clist.begin();
it != clist.end(); ++it) {
if ((*it)->isClean())
continue;
Buffer * c = *it;
// If a child is dirty, do not close
// without user intervention
if (!closeBuffer(*c, false)) {
closing_ = false;
close_event->ignore();
return;
}
}
QList<int> const ids = guiApp->viewIds();
for (int i = 0; i != ids.size(); ++i) {
if (id_ == ids[i])
continue;
if (guiApp->view(ids[i]).workArea(*b)) {
// FIXME 1: should we put an alert box here that the buffer
// is viewed elsewhere?
// FIXME 2: should we try to save this buffer in any case?
//saveBuffer(b);
// This buffer is also opened in another view, so
// close the associated work area...
removeWorkArea(d.current_work_area_);
// ... but don't close the buffer.
b = 0;
break;
}
}
if (b && !closeBuffer(*b, true)) {
closing_ = false;
close_event->ignore();
return;
}
continue;
}
vector<Buffer *> clist = b->getChildren();
for (vector<Buffer *>::const_iterator it = clist.begin();
it != clist.end(); ++it) {
if ((*it)->isClean())
continue;
Buffer * c = *it;
// If a child is dirty, do not close
// without user intervention
if (!closeBuffer(*c, false)) {
closing_ = false;
close_event->ignore();
return;
}
}
QList<int> const ids = guiApp->viewIds();
for (int i = 0; i != ids.size(); ++i) {
if (id_ == ids[i])
continue;
if (guiApp->view(ids[i]).workArea(*b)) {
// FIXME 1: should we put an alert box here that the buffer
// is viewed elsewhere?
// FIXME 2: should we try to save this buffer in any case?
//saveBuffer(b);
// This buffer is also opened in another view, so
// close the associated work area...
removeWorkArea(d.current_work_area_);
// ... but don't close the buffer.
b = 0;
break;
}
}
if (b && !closeBuffer(*b, true)) {
closing_ = false;
close_event->ignore();
return;
}
}
// Make sure that nothing will use this close to be closed View.
guiApp->unregisterView(this);