]> git.lyx.org Git - features.git/commitdiff
Get rid of indirections and add a check.
authorAbdelrazak Younes <younes@lyx.org>
Fri, 12 Sep 2008 13:36:40 +0000 (13:36 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Fri, 12 Sep 2008 13:36:40 +0000 (13:36 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26370 a592a061-630c-0410-9148-cb99ea01b6c8

src/CutAndPaste.cpp

index 813d28a2e350787f0c918c8ea6f49f479dadf764..6652b2ef5b54548aa1af85426e010dba4ab58cc9 100644 (file)
@@ -96,7 +96,9 @@ pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist,
        Buffer const & buffer = cur.buffer();
        pit_type pit = cur.pit();
        pos_type pos = cur.pos();
-       ParagraphList & pars = cur.text()->paragraphs();
+       InsetText * target_inset = cur.inset().asInsetText();
+       LASSERT(target_inset, return make_pair(PitPosPair(pit, pos), pit));
+       ParagraphList & pars = target_inset->paragraphs();
 
        if (parlist.empty())
                return make_pair(PitPosPair(pit, pos), pit);
@@ -190,11 +192,11 @@ pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist,
                        max_depth = tmpbuf->getMaxDepthAfter();
 
                // Set the inset owner of this paragraph.
-               tmpbuf->setInsetOwner(pars[pit].inInset());
+               tmpbuf->setInsetOwner(target_inset);
                for (pos_type i = 0; i < tmpbuf->size(); ++i) {
                        // do not track deletion of invalid insets
                        if (Inset * inset = tmpbuf->getInset(i))
-                               if (!pars[pit].insetAllowed(inset->lyxCode()))
+                               if (target_inset->insetAllowed(inset->lyxCode()))
                                        tmpbuf->eraseChar(i--, false);
                }