mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-23 00:38:01 +00:00
Make a new function to check whether a workArea is also shown in another view.
Use this function in closeBufferAll, and use closeBuffer to hide the buffer. Now, closeBuffer will decide whether we need to save the buffer or not. Previously, the buffer got hidden even if it was dirty. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31059 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
e445666594
commit
7372c173a6
@ -631,27 +631,13 @@ bool GuiView::closeBufferAll(bool tolastopened)
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
// We only want to close the buffer if the same buffer is not in
|
||||
// another view.
|
||||
bool const close_buffer = !inMultiViews(wa);
|
||||
|
||||
// This buffer is also opened in another view, so
|
||||
// close the associated work area...
|
||||
removeWorkArea(wa);
|
||||
// ... but don't close the buffer.
|
||||
b = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// closeBuffer() needs buffer workArea still alive and
|
||||
// set as currrent one, and destroys it
|
||||
if (b && !closeBuffer(*b, true, tolastopened, is_active_wa))
|
||||
if (b && !closeBuffer(*b, close_buffer, tolastopened, is_active_wa))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -2026,6 +2012,23 @@ bool GuiView::saveBufferIfNeeded(Buffer & buf, bool hiding)
|
||||
}
|
||||
|
||||
|
||||
bool GuiView::inMultiViews(GuiWorkArea * wa)
|
||||
{
|
||||
QList<int> const ids = guiApp->viewIds();
|
||||
Buffer & buf = wa->bufferView().buffer();
|
||||
|
||||
int found_twa = 0;
|
||||
for (int i = 0; i != ids.size() && found_twa <= 1; ++i) {
|
||||
if (id_ == ids[i])
|
||||
continue;
|
||||
|
||||
if (guiApp->view(ids[i]).workArea(buf))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np)
|
||||
{
|
||||
Buffer * const curbuf = buffer();
|
||||
|
@ -304,6 +304,8 @@ private:
|
||||
bool saveBufferIfNeeded(Buffer & buf, bool hiding);
|
||||
///
|
||||
bool closeBufferAll(bool tolastopened = false);
|
||||
/// is the buffer in this workarea also shown in another view ?
|
||||
bool inMultiViews(GuiWorkArea * wa);
|
||||
///
|
||||
enum NextOrPrevious {
|
||||
NEXTBUFFER,
|
||||
|
Loading…
x
Reference in New Issue
Block a user