Fix bug 3062, bookmark-goto x crashes lyx for invalid bookmark

* src/session.C: check validity of temp bookmark
	* src/lyxfunc.C: check validity of bookmark in GOTO_BOOKMARK
	* lib/bind/*.bind: remove shortcuts to bookmark-save 2/3/4/5


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16589 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Bo Peng 2007-01-07 22:41:54 +00:00
parent 000df02671
commit 57686e9d61
6 changed files with 6 additions and 18 deletions

View File

@ -168,10 +168,6 @@
\bind "C-~S-4" "bookmark-goto 4"
\bind "C-~S-5" "bookmark-goto 5"
\bind "C-M-~S-1" "bookmark-save 1"
\bind "C-M-~S-2" "bookmark-save 2"
\bind "C-M-~S-3" "bookmark-save 3"
\bind "C-M-~S-4" "bookmark-save 4"
\bind "C-M-~S-5" "bookmark-save 5"
#

View File

@ -158,10 +158,6 @@
\bind "C-~S-4" "bookmark-goto 4"
\bind "C-~S-5" "bookmark-goto 5"
\bind "C-M-~S-1" "bookmark-save 1"
\bind "C-M-~S-2" "bookmark-save 2"
\bind "C-M-~S-3" "bookmark-save 3"
\bind "C-M-~S-4" "bookmark-save 4"
\bind "C-M-~S-5" "bookmark-save 5"
# The below are xemacs bindings
#\bind "Home" "line-begin"

View File

@ -155,10 +155,6 @@
\bind "C-~S-4" "bookmark-goto 4"
\bind "C-~S-5" "bookmark-goto 5"
\bind "C-M-~S-1" "bookmark-save 1"
\bind "C-M-~S-2" "bookmark-save 2"
\bind "C-M-~S-3" "bookmark-save 3"
\bind "C-M-~S-4" "bookmark-save 4"
\bind "C-M-~S-5" "bookmark-save 5"
#

View File

@ -173,10 +173,6 @@
\bind "C-~S-4" "bookmark-goto 4"
\bind "C-~S-5" "bookmark-goto 5"
\bind "C-M-~S-1" "bookmark-save 1"
\bind "C-M-~S-2" "bookmark-save 2"
\bind "C-M-~S-3" "bookmark-save 3"
\bind "C-M-~S-4" "bookmark-save 4"
\bind "C-M-~S-5" "bookmark-save 5"
#
# Motion + select group

View File

@ -1673,6 +1673,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
case LFUN_BOOKMARK_GOTO: {
BOOST_ASSERT(lyx_view_);
unsigned int idx = convert<unsigned int>(to_utf8(cmd.argument()));
if (!LyX::ref().session().bookmarks().isValid(idx))
break;
BookmarksSection::Bookmark const bm = LyX::ref().session().bookmarks().bookmark(idx);
BOOST_ASSERT(!bm.filename.empty());
string const file = bm.filename.absFilename();

View File

@ -296,8 +296,10 @@ void BookmarksSection::save(FileName const & fname, int par_id, pos_type par_pos
bool BookmarksSection::isValid(unsigned int i) const
{
// i == 0, or in the queue
return i <= bookmarks.size();
if (i == 0)
return !temp_bookmark.filename.empty();
else
return i <= bookmarks.size() && !bookmarks[i-1].filename.empty();
}