From: Jürgen Spitzmüller Date: Thu, 24 Nov 2005 16:22:39 +0000 (+0000) Subject: fix initialization of insetOwner after undo (bug 1952). X-Git-Tag: 1.6.10~13780 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=f200823716565c4c37046f32daca40eaf70223dc;p=features.git fix initialization of insetOwner after undo (bug 1952). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10619 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index 9658d711d2..89edf764a7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2005-11-17 Jürgen Spitzmüller + + * dociterator.[Ch]: new member realInset() that returns the cell + for tabulars and the inset for the rest (bug 1952). + * undo.C (textUndoOrRedo): use realInset when resetting insetOwner + (bug 1952). + 2005-11-15 Jean-Marc Lasgouttes * text.C (leftMargin): honor the NextNoIndent tag in layouts. diff --git a/src/dociterator.C b/src/dociterator.C index 51ecd64067..0b3e0567ec 100644 --- a/src/dociterator.C +++ b/src/dociterator.C @@ -20,6 +20,7 @@ #include "mathed/math_data.h" #include "mathed/math_inset.h" +#include "insets/insettabular.h" #include #include @@ -90,6 +91,18 @@ InsetBase const * DocIterator::prevInset() const } +InsetBase * DocIterator::realInset() const +{ + BOOST_ASSERT(inTexted()); + // if we are in a tabular, we need the cell + if (inset().lyxCode() == InsetBase::TABULAR_CODE) { + InsetTabular & tabular = static_cast(inset()); + return tabular.cell(idx()).get(); + } + return &inset(); +} + + MathAtom const & DocIterator::prevAtom() const { BOOST_ASSERT(!empty()); diff --git a/src/dociterator.h b/src/dociterator.h index c69c703c51..fa6824b88f 100644 --- a/src/dociterator.h +++ b/src/dociterator.h @@ -164,6 +164,8 @@ public: LyXText * text(); /// LyXText const * text() const; + /// the containing inset or the cell, respectively + InsetBase * realInset() const; /// InsetBase * innerInsetOfType(int code) const; /// diff --git a/src/undo.C b/src/undo.C index d5d34c0c4a..8e5fcc334f 100644 --- a/src/undo.C +++ b/src/undo.C @@ -187,10 +187,10 @@ bool textUndoOrRedo(BufferView & bv, // this ugly stuff is needed until we get rid of the // inset_owner backpointer - ParagraphList::const_iterator pit = undo.pars.begin(); - ParagraphList::const_iterator end = undo.pars.end(); + ParagraphList::iterator pit = undo.pars.begin(); + ParagraphList::iterator const end = undo.pars.end(); for (; pit != end; ++pit) - const_cast(*pit).setInsetOwner(&dit.inset()); + pit->setInsetOwner(dit.realInset()); plist.insert(first, undo.pars.begin(), undo.pars.end()); }