Fix more possible crashes due to asInsetRef()

InsetMathHull has no method asInsetRef() and returns therefore 0.

See also 5bd68605.
This commit is contained in:
Vincent van Ravesteijn 2012-03-23 21:15:55 +01:00
parent 5bd68605df
commit 87d97322ef
2 changed files with 9 additions and 10 deletions

View File

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

View File

@ -74,8 +74,8 @@ What's new
* USER INTERFACE * USER INTERFACE
- Fixed crash when modifying equation label and there are references to that - Fixed crash when modifying or pasting an equation label and there
label in math (bug 8095). are references to that label in math (bug 8095).
- Do not disable View/Update Other Formats button when "Use non-TeX fonts" - Do not disable View/Update Other Formats button when "Use non-TeX fonts"
is active (bug 8069). is active (bug 8069).