]> git.lyx.org Git - lyx.git/commitdiff
Fix bug 3171: switching document jumps always back to last saved bookmark
authorAbdelrazak Younes <younes@lyx.org>
Tue, 19 Jun 2007 17:57:40 +0000 (17:57 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Tue, 19 Jun 2007 17:57:40 +0000 (17:57 +0000)
http://bugzilla.lyx.org/show_bug.cgi?id=3171

* LyXFunc::closeBuffer(): remove code that is already done on Buffer deletion thanks to the Buffer::closing() signal connection to LyXView. Setting the Buffer twice was part of the reason of the bug.

* BufferView::setBuffer(): properly update the metrics if we move to a saved cursor position.

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

src/BufferView.cpp
src/LyXFunc.cpp

index 61b196fbb5657de98ac3ae5c26d2d42880cb5fce..6e2ad8115a60a8fc4f769483b0cba5ceb42014ee 100644 (file)
@@ -214,6 +214,12 @@ void BufferView::setBuffer(Buffer * b)
        cursor_.push(buffer_->inset());
        cursor_.resetAnchor();
        buffer_->text().setCurrentFont(cursor_);
+
+       // Update the metrics now that we have a proper Cursor.
+       updateMetrics(false);
+
+       // FIXME: This code won't be needed once we switch to
+       // "one Buffer" / "one BufferView".
        if (buffer_->getCursor().size() > 0 &&
                        buffer_->getAnchor().size() > 0)
        {
@@ -227,12 +233,17 @@ void BufferView::setBuffer(Buffer * b)
                // Make sure that the restored cursor is not broken. This can happen for
                // example if this Buffer has been modified by another view.
                cursor_.fixIfBroken();
+
+               if (fitCursor())
+                       // Update the metrics if the cursor new position was off screen.
+                       updateMetrics(false);
        }
-       updateMetrics(false);
+
        if (graphics::Previews::status() != LyXRC::PREVIEW_OFF)
                graphics::Previews::get().generateBufferPreviews(*buffer_);
 }
 
+
 void BufferView::resize()
 {
        if (!buffer_)
index f549847e39ace99b6ce4d1f42bc7ee95d9573961..27f558a5fbb4cfff95810d829d61f6356ced4813 100644 (file)
@@ -2089,16 +2089,8 @@ void LyXFunc::closeBuffer()
        // goto bookmark to update bookmark pit.
        for (size_t i = 0; i < LyX::ref().session().bookmarks().size(); ++i)
                gotoBookmark(i+1, false, false);
-       if (theBufferList().close(lyx_view_->buffer(), true) && !quitting) {
-               if (theBufferList().empty()) {
-                       // need this otherwise SEGV may occur while
-                       // trying to set variables that don't exist
-                       // since there's no current buffer
-                       lyx_view_->getDialogs().hideBufferDependent();
-               } else {
-                       lyx_view_->setBuffer(theBufferList().first());
-               }
-       }
+       
+       theBufferList().close(lyx_view_->buffer(), true);
 }