]> git.lyx.org Git - features.git/commitdiff
Fix a few quirks and a crash introduced by a bad manual merge of local tree at revisi...
authorAbdelrazak Younes <younes@lyx.org>
Tue, 19 Jun 2007 17:04:09 +0000 (17:04 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Tue, 19 Jun 2007 17:04:09 +0000 (17:04 +0000)
* LyXView::setBuffer(): update labels and toc only if we change parents.
* LyXView::loadLyXFile():
  - update labels in _any_ case and before setting the Buffer.
  - update GUI controls in case we move to a saved position.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18829 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/LyXView.cpp

index cdbcc66e1661d43a3101fb496620ae609892dda6..dbf474462df9acdcdf25cc028c08a9e8c289f31e 100644 (file)
@@ -143,21 +143,19 @@ 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);
+               }
+
+               connectBuffer(*newBuffer);
 
                // Buffer-dependent dialogs should be updated or
                // hidden. This should go here because some dialogs (eg ToC)
@@ -209,15 +207,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 +227,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();
                }
        }