From 608603a31d6ae4e3d08ae4e9c18a11d9e705dcf4 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Tue, 19 Jun 2007 17:57:40 +0000 Subject: [PATCH] Fix bug 3171: switching document jumps always back to last saved bookmark 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 | 13 ++++++++++++- src/LyXFunc.cpp | 12 ++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 61b196fbb5..6e2ad8115a 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -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_) diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index f549847e39..27f558a5fb 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -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); } -- 2.39.5