]> git.lyx.org Git - features.git/commitdiff
Fix more possible crashes due to asInsetRef()
authorVincent van Ravesteijn <vfr@lyx.org>
Fri, 23 Mar 2012 20:15:55 +0000 (21:15 +0100)
committerVincent van Ravesteijn <vfr@lyx.org>
Fri, 23 Mar 2012 22:01:35 +0000 (23:01 +0100)
InsetMathHull has no method asInsetRef() and returns therefore 0.

See also 447e0d03.

src/CutAndPaste.cpp

index c8e99abcabb9cb3b894e033299f0e9b674c93d0a..2e0ae40f0b65e259e8c1324a085ff6b1b604737a 100644 (file)
@@ -256,13 +256,13 @@ pasteSelectionHelper(Cursor const & cur, ParagraphList const & parlist,
                                                if (ref->getParam("reference") == oldname)
                                                        ref->setParam("reference", newname);
                                        } else if (itt->lyxCode() == MATH_REF_CODE) {
-                                               InsetMathHull * mi = itt->asInsetMath()->asHullInset();
+                                               InsetMathRef * mi = itt->asInsetMath()->asRefInset();
                                                // this is necessary to prevent an uninitialized
                                                // buffer when the RefInset is in a MathBox.
                                                // FIXME audit setBuffer calls
                                                mi->setBuffer(const_cast<Buffer &>(buffer));
-                                               if (mi->asRefInset()->getTarget() == oldname)
-                                                       mi->asRefInset()->changeTarget(newname);
+                                               if (mi->getTarget() == oldname)
+                                                       mi->changeTarget(newname);
                                        }
                                }
                        }
@@ -286,14 +286,13 @@ pasteSelectionHelper(Cursor const & cur, ParagraphList const & parlist,
                                        if (ref.getParam("reference") == oldname)
                                                ref.setParam("reference", newname);
                                } else if (itt->lyxCode() == MATH_REF_CODE) {
-                                       InsetMathHull & mi =
-                                               static_cast<InsetMathHull &>(*itt);
+                                       InsetMathRef * mi = itt->asInsetMath()->asRefInset();
                                        // this is necessary to prevent an uninitialized
                                        // buffer when the RefInset is in a MathBox.
                                        // FIXME audit setBuffer calls
-                                       mi.setBuffer(const_cast<Buffer &>(buffer));
-                                       if (mi.asRefInset()->getTarget() == oldname)
-                                               mi.asRefInset()->changeTarget(newname);
+                                       mi->setBuffer(const_cast<Buffer &>(buffer));
+                                       if (mi->getTarget() == oldname)
+                                               mi->changeTarget(newname);
                                }
                        }
                        break;