Fix use of BookmarkSection::size()

The value was 9 instead of 10, which forced its users to use unusual code.
This commit is contained in:
Jean-Marc Lasgouttes 2021-01-06 19:18:25 +01:00
parent e1261817d2
commit b64b1aa85e
4 changed files with 8 additions and 6 deletions

View File

@ -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;
}

View File

@ -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();

View File

@ -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();

View File

@ -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();