mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 02:28:35 +00:00
Dissect closeBufferAll and closeTabWorkArea. Unfortunately, I have two pass ugly parameters.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31122 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
6bc8b8c592
commit
0e5f082a57
@ -600,24 +600,11 @@ bool GuiView::closeBufferAll(bool in_close_event)
|
||||
for (; d.splitter_->count() > empty_twa; ) {
|
||||
TabWorkArea * twa = d.tabWorkArea(empty_twa);
|
||||
|
||||
int twa_count = twa->count();
|
||||
if (twa->count() == 0)
|
||||
++empty_twa;
|
||||
|
||||
for (; twa == d.tabWorkArea(empty_twa) && twa_count; --twa_count) {
|
||||
twa->setCurrentIndex(twa_count-1);
|
||||
|
||||
GuiWorkArea * wa = twa->currentWorkArea();
|
||||
bool const is_active_wa = active_wa == wa;
|
||||
Buffer & b = wa->bufferView().buffer();
|
||||
|
||||
// We only want to close the buffer if the same buffer is not in
|
||||
// another view.
|
||||
bool const close_buffer = !(inMultiViews(wa) || b.parent());
|
||||
|
||||
// closeBuffer() needs buffer workArea still alive and
|
||||
// set as currrent one, and destroys it
|
||||
if (!closeWorkArea(wa, close_buffer, in_close_event, is_active_wa))
|
||||
else {
|
||||
setCurrentWorkArea(twa->currentWorkArea());
|
||||
if (!closeTabWorkArea(twa, true, active_wa))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1960,6 +1947,31 @@ bool GuiView::closeWorkArea(GuiWorkArea * wa, bool close_buffer,
|
||||
}
|
||||
|
||||
|
||||
bool GuiView::closeTabWorkArea(TabWorkArea * twa, bool in_close_event,
|
||||
GuiWorkArea * main_work_area)
|
||||
{
|
||||
while (twa == d.currentTabWorkArea()) {
|
||||
twa->setCurrentIndex(twa->count()-1);
|
||||
|
||||
GuiWorkArea * wa = twa->currentWorkArea();
|
||||
bool const is_active_wa = main_work_area == wa;
|
||||
Buffer & b = wa->bufferView().buffer();
|
||||
|
||||
// We only want to close the buffer if the same buffer is not visible
|
||||
// in another view, and if this is not a child and if we are closing
|
||||
// a view (not a tabgroup).
|
||||
bool const close_buffer =
|
||||
!inMultiViews(wa) && !b.parent() && in_close_event;
|
||||
|
||||
// closeBuffer() needs buffer workArea still alive and
|
||||
// set as currrent one, and destroys it
|
||||
if (!closeWorkArea(wa, close_buffer, true, is_active_wa))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool GuiView::saveBufferIfNeeded(Buffer & buf, bool hiding)
|
||||
{
|
||||
if (buf.isClean() || buf.paragraphs().empty())
|
||||
|
Loading…
Reference in New Issue
Block a user