]> git.lyx.org Git - features.git/commitdiff
fix bug 913 (toc crash)
authorJohn Levon <levon@movementarian.org>
Sat, 22 Feb 2003 20:05:13 +0000 (20:05 +0000)
committerJohn Levon <levon@movementarian.org>
Sat, 22 Feb 2003 20:05:13 +0000 (20:05 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6233 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/insets/ChangeLog
src/insets/insetfloat.C
src/insets/insetwrap.C
src/toc.C
src/toc.h

index ca3329bcba5b43b2c932f4a0f33cd0991d12975e..977f127d754f50e02a850ce514c3f2cfc99fd15c 100644 (file)
@@ -1,3 +1,9 @@
+2003-02-22  John Levon  <levon@movementarian.org>
+
+       * toc.h:
+       * toc.C: make TocItem store an id not a Paragraph *
+         (bug #913)
+
 2003-02-21  Angus Leeming  <leeming@lyx.org>
 
        * BufferView_pimpl.C (MenuInsertLyXFile):
index 9964b61e184e42000c8df51d5398f4c66e959c5c..115278a745aa598f62a5c6c7afb36329e0bba8bf 100644 (file)
@@ -1,3 +1,8 @@
+2003-02-22  John Levon  <levon@movementarian.org>
+
+       * insetfloat.C:
+       * insetwrap.C: TocItem changed API (bug 913)
+
 2003-02-21  Angus Leeming  <leeming@lyx.org>
        
        * updatableinset.h (setView, view): remove.
index b43540ccdc1ea5d4f3240f2c4dcdecd54529de1f..8f5232ffe561f9141e726bc362bb2af53ecee905 100644 (file)
@@ -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);
                }
        }
index adc97759b53b446044c99948dab1f27d727d858d..b48a1327e4b00efffbb8f27853e940d2163275a1 100644 (file)
@@ -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();
index ffc55f5d4f8c6b9da740ddfe565abb49c3dd7c3a..2db88e4af9ad6a52c04d9baf2ed63570e18d9a31 100644 (file)
--- 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);
                }
index e7f8e7daa9420d357351f90a2826f141589209db..956101d13296eac2b93c766631830193a83623f7 100644 (file)
--- 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.
 }