work_area_->bufferView().setBuffer(b);
- //FIXME This would be a little simpler if setBuffer returned the buffer.
+ //FIXME This would be a little simpler if setBuffer returned the buffer.
Buffer * newBuffer = work_area_->bufferView().buffer();
if (newBuffer) {
- if (child_document && newBuffer != oldBuffer) {
+ if (child_document && newBuffer->getMasterBuffer() != oldBuffer) {
// Set the parent name of the child document.
// This makes insertion of citations and references in the child work,
// when the target is in the parent or another child document.
newBuffer->setParentName(parentfilename);
- // updateLabels() will emit Buffer::structureChanged() so better
- // connect it before.
- connectBuffer(*newBuffer);
- // Update the labels and section numbering.
+ // Update the labels and section numbering to the new master Buffer.
updateLabels(*newBuffer->getMasterBuffer());
- } else
- connectBuffer(*newBuffer);
+ }
+
+ if (!b && oldBuffer && oldBuffer->getMasterBuffer() != oldBuffer)
+ // We are closing oldBuffer which was a child document so we
+ // must update the labels and section numbering of its master
+ // Buffer.
+ updateLabels(*oldBuffer->getMasterBuffer());
+
+ connectBuffer(*newBuffer);
+
+ /* FIXME: We need to rebuild the Toc dialog before the others even
+ if it will be rebuilt again in the next line. This avoid a crash when
+ other dialogs are rebuilt before the Toc dialog. The reason is
+ that closing a Buffer triggers an update of all opened dialogs
+ when dispatching LFUN_DIALOG_UPDATE (hence the patch).
+ The path is as following:
+ setBuffer() -> updateBufferDependent() -> RestoreButton() -> LFUN
+ The problem here is that the Toc dialog has not been
+ reconstructed (because it comes after in the list of dialogs). */
+ updateToc();
// Buffer-dependent dialogs should be updated or
// hidden. This should go here because some dialogs (eg ToC)
makeDisplayPath(filename.absFilename())));
}
+ // Update the labels and section numbering.
+ updateLabels(*newBuffer->getMasterBuffer());
+
bool const parse_error = !newBuffer->errorList("Parse").empty();
if (parse_error || !auto_open) {
setBuffer(newBuffer, child_document);
showErrorList("Parse");
}
- // Update the labels and section numbering.
- updateLabels(*newBuffer->getMasterBuffer());
-
// scroll to the position when the file was last closed
if (!auto_open && lyxrc.use_lastfilepos) {
pit_type pit;
if (work_area_->bufferView().fitCursor())
work_area_->bufferView().updateMetrics(false);
newBuffer->text().setCurrentFont(work_area_->bufferView().cursor());
+ updateMenubar();
+ updateToolbars();
+ updateLayoutChoice();
+ updateStatusBar();
+ work_area_->redraw();
}
}
}
-ToolbarInfo::Flags LyXView::getToolbarState(string const & name)
+ToolbarInfo * LyXView::getToolbarInfo(string const & name)
{
- return toolbars_->getToolbarState(name);
+ return toolbars_->getToolbarInfo(name);
}