Jürgen Spitzmüller wrote:
Abdelrazak Younes wrote:
Use case:

1) Open doc1
2) scroll a bit
3) open doc2
4) close doc2

Bug: The cursor is not at last position of doc1 and the screen is not
redrawn.

This is bug 3171, right?
http://bugzilla.lyx.org/show_bug.cgi?id=3171

Actually the fix for bug 3171 is in Buffer::setBuffer(). But the fix to the bug above is needed for bug 3171 too.

OK, who said OK?

Abdel.
Index: BufferView.cpp
===================================================================
--- BufferView.cpp      (revision 18828)
+++ BufferView.cpp      (working copy)
@@ -209,11 +209,14 @@
        if (!buffer_)
                return;
 
+       updateMetrics(false);
+
        LYXERR(Debug::INFO) << BOOST_CURRENT_FUNCTION
                                        << "Buffer addr: " << buffer_ << endl;
        cursor_.push(buffer_->inset());
        cursor_.resetAnchor();
        buffer_->text().setCurrentFont(cursor_);
+
        if (buffer_->getCursor().size() > 0 &&
                        buffer_->getAnchor().size() > 0)
        {
@@ -227,12 +230,15 @@
                // 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())
+                       updateMetrics(false);
        }
-       updateMetrics(false);
+
        if (graphics::Previews::status() != LyXRC::PREVIEW_OFF)
                graphics::Previews::get().generateBufferPreviews(*buffer_);
 }
 
+
 void BufferView::resize()
 {
        if (!buffer_)
Index: LyXFunc.cpp
===================================================================
--- LyXFunc.cpp (revision 18827)
+++ LyXFunc.cpp (working copy)
@@ -2089,16 +2089,8 @@
        // 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);
 }
 
 

Reply via email to