Explicitly pass to closeBuffer whether the tab should only be hidden or that the buffer should be released.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30993 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2009-08-12 20:03:34 +00:00
parent 3ac3ab1a78
commit 5ba1f471c7
2 changed files with 10 additions and 9 deletions

View File

@ -607,7 +607,7 @@ bool GuiView::closeBufferAll(bool tolastopened)
if (b->parent()) { if (b->parent()) {
// This is a child document, just close the tab // This is a child document, just close the tab
// after saving but keep the file loaded. // after saving but keep the file loaded.
if (!closeBuffer(*b, tolastopened, is_active_wa)) if (!closeBuffer(*b, false, tolastopened, is_active_wa))
return false; return false;
continue; continue;
} }
@ -620,7 +620,8 @@ bool GuiView::closeBufferAll(bool tolastopened)
Buffer * c = *it; Buffer * c = *it;
// If a child is dirty, do not close // If a child is dirty, do not close
// without user intervention // without user intervention
if (!closeBuffer(*c, false)) //FIXME: should buffers be closed or not?
if (!closeBuffer(*c, false, false))
return false; return false;
} }
@ -644,7 +645,7 @@ bool GuiView::closeBufferAll(bool tolastopened)
} }
// closeBuffer() needs buffer workArea still alive and // closeBuffer() needs buffer workArea still alive and
// set as currrent one, and destroys it // set as currrent one, and destroys it
if (b && !closeBuffer(*b, tolastopened, is_active_wa)) if (b && !closeBuffer(*b, true, tolastopened, is_active_wa))
return false; return false;
} }
} }
@ -1925,11 +1926,12 @@ bool GuiView::saveBuffer(Buffer & b)
bool GuiView::closeBuffer() bool GuiView::closeBuffer()
{ {
Buffer * buf = buffer(); Buffer * buf = buffer();
return buf && closeBuffer(*buf); return buf && closeBuffer(*buf, !buf->parent());
} }
bool GuiView::closeBuffer(Buffer & buf, bool tolastopened, bool mark_active) bool GuiView::closeBuffer(Buffer & buf, bool close_buffer,
bool tolastopened, bool mark_active)
{ {
// goto bookmark to update bookmark pit. // goto bookmark to update bookmark pit.
//FIXME: we should update only the bookmarks related to this buffer! //FIXME: we should update only the bookmarks related to this buffer!
@ -1943,8 +1945,7 @@ bool GuiView::closeBuffer(Buffer & buf, bool tolastopened, bool mark_active)
// is opened as well // is opened as well
if (tolastopened) if (tolastopened)
theSession().lastOpened().add(buf.fileName(), mark_active); theSession().lastOpened().add(buf.fileName(), mark_active);
if (buf.parent()) if (!close_buffer)
// Don't close child documents.
removeWorkArea(currentMainWorkArea()); removeWorkArea(currentMainWorkArea());
else else
theBufferList().release(&buf); theBufferList().release(&buf);

View File

@ -294,8 +294,8 @@ private:
/// ///
bool saveBuffer(Buffer & b); bool saveBuffer(Buffer & b);
/// ///
bool closeBuffer(Buffer & buf, bool tolastopened = false, bool closeBuffer(Buffer & buf, bool keep_buffer,
bool mark_active = false); bool tolastopened = false, bool mark_active = false);
/// ///
bool saveBufferIfNeeded(Buffer & buf); bool saveBufferIfNeeded(Buffer & buf);
/// ///