]> git.lyx.org Git - features.git/commitdiff
undo undo leak fix that leked into the code, toc crash fix from John
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 14 Dec 2001 09:16:01 +0000 (09:16 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 14 Dec 2001 09:16:01 +0000 (09:16 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3208 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormToc.C
src/undo_funcs.C

index fd5a065a91513b0608e8d5c4daaeb69d615b6050..2d3cfd4cd0275e012b4e6cccd645c122ba30ff06 100644 (file)
@@ -1,3 +1,7 @@
+2001-12-13  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
+
+       * undo_funcs.C (textHandleUndo): undo undo leak fix below, as per
+       Juergen's request
 
 2001-12-13  André Pönitz <poenitz@gmx.net>
 
index b21e34d7e5e296e3e6e17f8ca37bc60e16989d7d..0dc1b16869e8f02a651e14c6edced36df64775b3 100644 (file)
@@ -1,3 +1,8 @@
+2001-12-14  John Levon  <moz@compsoc.man.ac.uk>
+
+       * FormToc.C: fix crash when no entries, and
+         update types properly
 2001-12-11  Ben Stanley <bds02@uow.edu.au>
 
        * Menubar_pimpl.C: Fixed a crashing bug when document has more
index 657a29f8902cc3ea61ef60b789e6b9d30c7796d9..97ce6e8d181f42b7d45eb76c8ed2b1ab47d69dc6 100644 (file)
@@ -55,8 +55,12 @@ void FormToc::update()
 }
 
 
-ButtonPolicy::SMInput FormToc::input(FL_OBJECT *, long)
+ButtonPolicy::SMInput FormToc::input(FL_OBJECT * ob, long)
 {
+       if (ob != dialog_->choice_toc_type) {
+               updateType();
+       }
        updateContents();
 
        unsigned int const choice = fl_get_browser( dialog_->browser_toc );
@@ -74,6 +78,7 @@ void FormToc::updateType()
        // Update the choice list from scratch
        fl_clear_choice(dialog_->choice_toc_type);
        string const choice = getStringFromVector(controller().getTypes(), "|");
+       lyxerr << "choice " << choice << endl; 
        fl_addto_choice(dialog_->choice_toc_type, choice.c_str());
 
        // And select the correct one
@@ -95,8 +100,16 @@ void FormToc::updateType()
 
 void FormToc::updateContents()
 {
-       string const type =
-               frontStrip(strip(fl_get_choice_text(dialog_->choice_toc_type)));
+       char const * tmp = fl_get_choice_text(dialog_->choice_toc_type);
+       if (!tmp) {
+               fl_clear_browser(dialog_->browser_toc);
+               fl_add_browser_line(dialog_->browser_toc,
+                                   _("*** No Lists ***"));
+               return;
+       }
+       string const type = frontStrip(strip(tmp));
 
        Buffer::SingleList const contents = controller().getContents(type);
 
index 175003ac25d4a442eaa2cfd68f80a7974f357934..dd064886687e56994423e06da8290ace1d35d978 100644 (file)
@@ -130,9 +130,9 @@ bool textHandleUndo(BufferView * bv, Undo * undo)
                                // the text informations. 
                                if (undo->kind == Undo::EDIT) {
                                        tmppar2->setContentsFromPar(tmppar);
+                                       tmppar->clearContents();
                                        tmppar2 = tmppar2->next();
                                }
-                               delete tmppar;
                        }
                }
     
@@ -141,20 +141,8 @@ bool textHandleUndo(BufferView * bv, Undo * undo)
                        if (before)
                                before->next(tmppar3);
                        else
-#warning Juergen, why is this needed?? (JMarc)
-// since tmppar3 is not yet inserted in the document, I do not see why
-// the getParFromID which is done by the function below makes sense.
-// OTOH, since you wrote the method just for this instance, I guess you
-// have something in mind
-#if 1
                                bv->text->ownerParagraph(tmppar3->id(),
                                                         tmppar3);
-#else
-// in this case, since getParFromID is not called, the program does
-// not crash on trying to access buffer()->paragraph, which does not
-// exist anymore if we undid the first par f the document. (JMarc)
-                               bv->text->ownerParagraph(tmppar3);
-#endif
 
                        tmppar3->previous(before);
                } else {