From: Vincent van Ravesteijn Date: Fri, 23 Mar 2012 20:15:55 +0000 (+0100) Subject: Fix more possible crashes due to asInsetRef() X-Git-Tag: 2.1.0beta1~1933^2~77 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=e409eedc5bd77d80af93a0b7c3ce19c53db8fbf0;p=features.git Fix more possible crashes due to asInsetRef() InsetMathHull has no method asInsetRef() and returns therefore 0. See also 447e0d03. --- diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index c8e99abcab..2e0ae40f0b 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -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)); - 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(*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)); - if (mi.asRefInset()->getTarget() == oldname) - mi.asRefInset()->changeTarget(newname); + mi->setBuffer(const_cast(buffer)); + if (mi->getTarget() == oldname) + mi->changeTarget(newname); } } break;