Dissect closeBuffer() and saveBufferIfNeeded().

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30992 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2009-08-12 18:50:09 +00:00
parent ac60f0318a
commit 3ac3ab1a78
2 changed files with 12 additions and 12 deletions

View File

@ -1937,7 +1937,7 @@ bool GuiView::closeBuffer(Buffer & buf, bool tolastopened, bool mark_active)
for (size_t i = 0; i < theSession().bookmarks().size(); ++i)
theLyXFunc().gotoBookmark(i+1, false, false);
if (buf.isClean() || buf.paragraphs().empty()) {
if (saveBufferIfNeeded(buf)) {
// save in sessions if requested
// do not save childs if their master
// is opened as well
@ -1950,6 +1950,15 @@ bool GuiView::closeBuffer(Buffer & buf, bool tolastopened, bool mark_active)
theBufferList().release(&buf);
return true;
}
return false;
}
bool GuiView::saveBufferIfNeeded(Buffer & buf)
{
if (buf.isClean() || buf.paragraphs().empty())
return true;
// Switch to this Buffer.
setBuffer(&buf);
@ -1983,17 +1992,6 @@ bool GuiView::closeBuffer(Buffer & buf, bool tolastopened, bool mark_active)
case 2:
return false;
}
// save file names to .lyx/session
if (tolastopened)
theSession().lastOpened().add(buf.fileName(), mark_active);
if (buf.parent())
// Don't close child documents.
removeWorkArea(currentMainWorkArea());
else
theBufferList().release(&buf);
return true;
}

View File

@ -297,6 +297,8 @@ private:
bool closeBuffer(Buffer & buf, bool tolastopened = false,
bool mark_active = false);
///
bool saveBufferIfNeeded(Buffer & buf);
///
bool closeBufferAll(bool tolastopened = false);
///
enum NextOrPrevious {