commit b64b1aa85e18a57878c96f697317340b7db1a169
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Wed Jan 6 19:18:25 2021 +0100

    Fix use of BookmarkSection::size()
    
    The value was 9 instead of 10, which forced its users to use unusual code.
---
 src/Session.cpp                     |    2 +-
 src/Session.h                       |    2 +-
 src/frontends/qt/GuiApplication.cpp |    5 +++--
 src/frontends/qt/GuiView.cpp        |    5 +++--
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/Session.cpp b/src/Session.cpp
index cfb2565..f8d6116 100644
--- a/src/Session.cpp
+++ b/src/Session.cpp
@@ -325,7 +325,7 @@ bool BookmarksSection::isValid(unsigned int i) const
 
 bool BookmarksSection::hasValid() const
 {
-       for (size_t i = 1; i <= size(); ++i) {
+       for (size_t i = 1; i < bookmarks.size(); ++i) {
                if (isValid(i))
                        return true;
        }
diff --git a/src/Session.h b/src/Session.h
index 9cbe6d8..09e9d7d 100644
--- a/src/Session.h
+++ b/src/Session.h
@@ -246,7 +246,7 @@ public:
        bool hasValid() const;
 
        ///
-       unsigned int size() const { return max_bookmarks; }
+       unsigned int size() const { return bookmarks.size(); }
 
        /// clear all bookmarks
        void clear();
diff --git a/src/frontends/qt/GuiApplication.cpp 
b/src/frontends/qt/GuiApplication.cpp
index 552a2ce..294787f 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -1684,9 +1684,10 @@ void GuiApplication::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
                break;
 
        case LFUN_WINDOW_CLOSE:
+               // FIXME: this is done also in GuiView::closeBuffer()!
                // update bookmark pit of the current buffer before window close
-               for (size_t i = 0; i < theSession().bookmarks().size(); ++i)
-                       gotoBookmark(i+1, false, false);
+               for (size_t i = 1; i < theSession().bookmarks().size(); ++i)
+                       gotoBookmark(i, false, false);
                // clear the last opened list, because
                // maybe this will end the session
                theSession().lastOpened().clear();
diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index ae8bc28..714af17 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -3297,9 +3297,10 @@ bool GuiView::closeBuffer(Buffer & buf)
        if (success) {
                // goto bookmark to update bookmark pit.
                // FIXME: we should update only the bookmarks related to this 
buffer!
+               // FIXME: this is done also in LFUN_WINDOW_CLOSE!
                LYXERR(Debug::DEBUG, "GuiView::closeBuffer()");
-               for (unsigned int i = 0; i < theSession().bookmarks().size(); 
++i)
-                       guiApp->gotoBookmark(i + 1, false, false);
+               for (unsigned int i = 1; i < theSession().bookmarks().size(); 
++i)
+                       guiApp->gotoBookmark(i, false, false);
 
                if (saveBufferIfNeeded(buf, false)) {
                        buf.removeAutosaveFile();
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to