From a5b68f2da24d79cc2d94b55ad05aec9e76bdd465 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Mon, 2 Dec 2013 16:13:08 +0100 Subject: [PATCH] Changes to llkeyframemotionparam.cpp as result of audit. These changes were the result of my Motion leak audit. However, there is a serious problem with LLKeyframeMotionParam in that it stores plain pointers to objects that can and will be deleted by other objects. Its the classicial LL example of coding non-Object-Oriented badly maintainable and instable code. I cannot make sure this won't go wrong for the simple fact that LLKeyframeMotionParam is not used at ALL in our code. Hence, the next commit will rather delete this file. This commit is merely to have a record of this finding. --- indra/llcharacter/llkeyframemotionparam.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/indra/llcharacter/llkeyframemotionparam.cpp b/indra/llcharacter/llkeyframemotionparam.cpp index 4df1ef46b..3f3a44e52 100644 --- a/indra/llcharacter/llkeyframemotionparam.cpp +++ b/indra/llcharacter/llkeyframemotionparam.cpp @@ -68,11 +68,18 @@ LLKeyframeMotionParam::~LLKeyframeMotionParam() iter != mParameterizedMotions.end(); ++iter) { motion_list_t& motionList = iter->second; +#if 0 + // Singu note: this class is NOT responsible for cleaning up paramMotion.mMotion. + // They were obtained in LLKeyframeMotionParam::addKeyframeMotion by calling + // LLCharacter::createMotion which returns LLMotionController::createMotion + // which is responsible for cleaning up (by storing the pointers in + // LLMotionController::mAllMotions). for (motion_list_t::iterator iter2 = motionList.begin(); iter2 != motionList.end(); ++iter2) { const ParameterizedMotion& paramMotion = *iter2; delete paramMotion.mMotion; } +#endif motionList.clear(); } mParameterizedMotions.clear(); @@ -98,7 +105,11 @@ LLMotion::LLMotionInitStatus LLKeyframeMotionParam::onInitialize(LLCharacter *ch { const ParameterizedMotion& paramMotion = *iter2; LLMotion* motion = paramMotion.mMotion; - motion->onInitialize(character); + if (motion->onInitialize(character) != STATUS_SUCCESS) + { + llwarns << "Skipping uninitialize motion!" << llendl; + continue; + } if (motion->getDuration() > mEaseInDuration) {