From c51ae2651cc46d0133960b649092a1ea4ecbf72c Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Wed, 7 Jan 2009 01:48:47 +0000 Subject: [PATCH] Correct enabling of the "Navigate->Bookmarks->Clear Bookmarks" menu item. * LyXFunc.cpp: Note that getStatus() always returned true for LFUN_BOOKMARK_CLEAR. This is because bookmarks().size() is hardcoded in the code to be 9 which is always larger than zero, obviously git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28014 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LyXFunc.cpp | 2 +- src/Session.cpp | 10 ++++++++++ src/Session.h | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 128feec03a..6d804557a4 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -519,7 +519,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const } case LFUN_BOOKMARK_CLEAR: - enable = theSession().bookmarks().size() > 0; + enable = theSession().bookmarks().hasValid(); break; // this one is difficult to get right. As a half-baked diff --git a/src/Session.cpp b/src/Session.cpp index 967786c93b..1aaf9c4be9 100644 --- a/src/Session.cpp +++ b/src/Session.cpp @@ -285,6 +285,16 @@ bool BookmarksSection::isValid(unsigned int i) const } +bool BookmarksSection::hasValid() const +{ + for (size_t i = 1; i <= size(); ++i) { + if (isValid(i)) + return true; + } + return false; +} + + BookmarksSection::Bookmark const & BookmarksSection::bookmark(unsigned int i) const { return bookmarks[i]; diff --git a/src/Session.h b/src/Session.h index d673da22e9..8756c00430 100644 --- a/src/Session.h +++ b/src/Session.h @@ -233,6 +233,9 @@ public: /// does the given bookmark have a saved position ? bool isValid(unsigned int i) const; + /// is there at least one bookmark that has a saved position ? + bool hasValid() const; + /// unsigned int size() const { return max_bookmarks; } -- 2.39.5