]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/LyXView.cpp
updated list of LyX translations
[lyx.git] / src / frontends / LyXView.cpp
index cdbcc66e1661d43a3101fb496620ae609892dda6..d02a2d93025830fdc2b11ec6ac1261139462ad1c 100644 (file)
@@ -143,21 +143,36 @@ void LyXView::setBuffer(Buffer * b, bool child_document)
 
        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)
@@ -209,15 +224,15 @@ bool LyXView::loadLyXFile(FileName const & filename, bool tolastfiles,
                        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;
@@ -229,6 +244,11 @@ bool LyXView::loadLyXFile(FileName const & filename, bool tolastfiles,
                        if (work_area_->bufferView().fitCursor())
                                work_area_->bufferView().updateMetrics(false);
                        newBuffer->text().setCurrentFont(work_area_->bufferView().cursor());
+                       updateMenubar();
+                       updateToolbars();
+                       updateLayoutChoice();
+                       updateStatusBar();
+                       work_area_->redraw();
                }
        }
 
@@ -397,9 +417,9 @@ void LyXView::updateToolbars()
 }
 
 
-ToolbarInfo::Flags LyXView::getToolbarState(string const & name)
+ToolbarInfo * LyXView::getToolbarInfo(string const & name)
 {
-       return toolbars_->getToolbarState(name);
+       return toolbars_->getToolbarInfo(name);
 }