From f413754ef5b053a1f42377175e7075b36a15eafe Mon Sep 17 00:00:00 2001 From: John Levon Date: Sat, 22 Feb 2003 20:05:13 +0000 Subject: [PATCH] fix bug 913 (toc crash) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6233 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 6 ++++++ src/insets/ChangeLog | 5 +++++ src/insets/insetfloat.C | 2 +- src/insets/insetwrap.C | 2 +- src/toc.C | 6 +++--- src/toc.h | 15 ++++++--------- 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index ca3329bcba..977f127d75 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2003-02-22 John Levon + + * toc.h: + * toc.C: make TocItem store an id not a Paragraph * + (bug #913) + 2003-02-21 Angus Leeming * BufferView_pimpl.C (MenuInsertLyXFile): diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 9964b61e18..115278a745 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2003-02-22 John Levon + + * insetfloat.C: + * insetwrap.C: TocItem changed API (bug 913) + 2003-02-21 Angus Leeming * updatableinset.h (setView, view): remove. diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index b43540ccdc..8f5232ffe5 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -349,7 +349,7 @@ void InsetFloat::addToToc(toc::TocList & toclist, Buffer const * buf) const string const str = tostr(toclist[name].size() + 1) + ". " + tmp->asString(buf, false); - toc::TocItem const item(tmp, 0 , str); + toc::TocItem const item(tmp->id(), 0 , str); toclist[name].push_back(item); } } diff --git a/src/insets/insetwrap.C b/src/insets/insetwrap.C index adc97759b5..b48a1327e4 100644 --- a/src/insets/insetwrap.C +++ b/src/insets/insetwrap.C @@ -261,7 +261,7 @@ void InsetWrap::addToToc(toc::TocList & toclist, Buffer const * buf) const string const str = tostr(toclist[name].size() + 1) + ". " + tmp->asString(buf, false); - toc::TocItem const item(tmp, 0 , str); + toc::TocItem const item(tmp->id(), 0 , str); toclist[name].push_back(item); } tmp = tmp->next(); diff --git a/src/toc.C b/src/toc.C index ffc55f5d4f..2db88e4af9 100644 --- a/src/toc.C +++ b/src/toc.C @@ -42,7 +42,7 @@ string const TocItem::asString() const void TocItem::goTo(LyXView & lv_) const { - string const tmp = tostr(par->id()); + string const tmp = tostr(id_); lv_.dispatch(FuncRequest(LFUN_GOTO_PARAGRAPH, tmp)); } @@ -50,7 +50,7 @@ void TocItem::goTo(LyXView & lv_) const int TocItem::action() const { return lyxaction.getPseudoAction(LFUN_GOTO_PARAGRAPH, - tostr(par->id())); + tostr(id_)); } @@ -86,7 +86,7 @@ TocList const getTocList(Buffer const * buf) && labeltype <= LABEL_COUNTER_CHAPTER + buf->params.tocdepth) { // insert this into the table of contents const int depth = max(0, labeltype - textclass.maxcounter()); - TocItem const item(par, depth, + TocItem const item(par->id(), depth, par->asString(buf, true)); toclist["TOC"].push_back(item); } diff --git a/src/toc.h b/src/toc.h index e7f8e7daa9..956101d132 100644 --- a/src/toc.h +++ b/src/toc.h @@ -35,17 +35,17 @@ namespace toc /// struct TocItem { - TocItem(Paragraph const * p, int d, string const & s) - : par(p), depth(d), str(s) {} + TocItem(int par_id, int d, string const & s) + : id_(par_id), depth(d), str(s) {} /// string const asString() const; /// set cursor in LyXView to this TocItem void goTo(LyXView & lv_) const; /// the action corresponding to the goTo above int action() const; - /// - Paragraph const * par; - /// + /// Paragraph ID containing this item + int id_; + /// nesting depth int depth; /// string str; @@ -69,21 +69,18 @@ void asciiTocList(string const &, Buffer const *, std::ostream &); by ControlToc::getContents() */ string const getType(string const & cmdName); -/// inline bool operator==(TocItem const & a, TocItem const & b) { - return a.par == b.par && a.str == b.str; + return a.id_ == b.id_ && a.str == b.str; // No need to compare depth. } -/// inline bool operator!=(TocItem const & a, TocItem const & b) { return !(a == b); - // No need to compare depth. } -- 2.39.2