Also check for dirty children on QUIT

Fixes rest of #11405
This commit is contained in:
Juergen Spitzmueller 2018-12-20 11:37:19 +01:00
parent 99bfe20120
commit 33344c6015

View File

@ -3043,39 +3043,46 @@ bool GuiView::closeWorkArea(GuiWorkArea * wa, bool close_buffer)
bool GuiView::closeBuffer(Buffer & buf) bool GuiView::closeBuffer(Buffer & buf)
{ {
// If we are in a close_event all children will be closed in some time,
// so no need to do it here. This will ensure that the children end up
// in the session file in the correct order. If we close the master
// buffer, we can close or release the child buffers here too.
bool success = true; bool success = true;
if (!closing_) { ListOfBuffers clist = buf.getChildren();
ListOfBuffers clist = buf.getChildren(); ListOfBuffers::const_iterator it = clist.begin();
ListOfBuffers::const_iterator it = clist.begin(); ListOfBuffers::const_iterator const bend = clist.end();
ListOfBuffers::const_iterator const bend = clist.end(); for (; it != bend; ++it) {
for (; it != bend; ++it) { Buffer * child_buf = *it;
Buffer * child_buf = *it; if (theBufferList().isOthersChild(&buf, child_buf)) {
if (theBufferList().isOthersChild(&buf, child_buf)) { child_buf->setParent(0);
child_buf->setParent(0); continue;
continue; }
}
// FIXME: should we look in other tabworkareas? // FIXME: should we look in other tabworkareas?
// ANSWER: I don't think so. I've tested, and if the child is // ANSWER: I don't think so. I've tested, and if the child is
// open in some other window, it closes without a problem. // open in some other window, it closes without a problem.
GuiWorkArea * child_wa = workArea(*child_buf); GuiWorkArea * child_wa = workArea(*child_buf);
if (child_wa) { if (child_wa) {
success = closeWorkArea(child_wa, true); if (closing_)
if (!success) // If we are in a close_event all children will be closed in some time,
break; // so no need to do it here. This will ensure that the children end up
} else { // in the session file in the correct order. If we close the master
// In this case the child buffer is open but hidden. // buffer, we can close or release the child buffers here too.
// Even in this case, children can be dirty (e.g., continue;
// after a label change in the master, see #11405). success = closeWorkArea(child_wa, true);
// Therefore, check this. if (!success)
if (saveBufferIfNeeded(*child_buf, false)) { break;
child_buf->removeAutosaveFile(); } else {
theBufferList().release(child_buf); // In this case the child buffer is open but hidden.
} // Even in this case, children can be dirty (e.g.,
// after a label change in the master, see #11405).
// Therefore, check this
if (closing_ && (child_buf->isClean() || child_buf->paragraphs().empty()))
// If we are in a close_event all children will be closed in some time,
// so no need to do it here. This will ensure that the children end up
// in the session file in the correct order. If we close the master
// buffer, we can close or release the child buffers here too.
continue;
// Save dirty buffers also if closing_!
if (saveBufferIfNeeded(*child_buf, false)) {
child_buf->removeAutosaveFile();
theBufferList().release(child_buf);
} }
} }
} }