]> 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>
Sat, 24 Mar 2012 10:12:42 +0000 (11:12 +0100)
InsetMathHull has no method asInsetRef() and returns therefore 0.

See also 5bd68605.

src/CutAndPaste.cpp
status.20x

index f3163c162af4e61a367be1d05d5e4f53851c0075..c767c93be73356fcdff1f1bd2a17dff52a511040 100644 (file)
@@ -255,13 +255,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);
                                        }
                                }
                        }
@@ -285,14 +285,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;
index fa47388a538503bcf13b1b945aff0f353615af45..0c263f22c80520326f4a19c9dda51ecb67ad2305 100644 (file)
@@ -74,8 +74,8 @@ What's new
 
 * USER INTERFACE
 
-- Fixed crash when modifying equation label and there are references to that
-  label in math (bug 8095).
+- Fixed crash when modifying or pasting an equation label and there
+  are references to that label in math (bug 8095).
 
 - Do not disable View/Update Other Formats button when "Use non-TeX fonts"
   is active (bug 8069).