From 9f434ab384c8ac4b9660f56c6f51c654c919c137 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sat, 5 Mar 2011 18:00:16 -0600 Subject: [PATCH] Null checks, initilizations, etc --- indra/llmath/llsdutil_math.cpp | 2 +- indra/newview/lldriverparam.cpp | 6 ++++++ indra/newview/llfilepicker.cpp | 4 ++-- indra/newview/llflexibleobject.cpp | 1 + indra/newview/llgesturemgr.cpp | 9 ++++----- indra/newview/llhudeffecttrail.cpp | 2 +- indra/newview/llhudrender.cpp | 13 +++++++------ indra/newview/llmanip.cpp | 18 ++++++++++-------- indra/newview/llmanipscale.cpp | 1 + indra/newview/llpanelface.cpp | 17 ++++++++++++----- indra/newview/llvosky.cpp | 5 ++++- indra/newview/llworld.cpp | 2 ++ 12 files changed, 51 insertions(+), 29 deletions(-) diff --git a/indra/llmath/llsdutil_math.cpp b/indra/llmath/llsdutil_math.cpp index c5176681c..1bd12ae51 100644 --- a/indra/llmath/llsdutil_math.cpp +++ b/indra/llmath/llsdutil_math.cpp @@ -34,7 +34,7 @@ #include "linden_common.h" -#include "llsdutil.h" +#include "llsdutil_math.h" #include "v3math.h" #include "v4math.h" diff --git a/indra/newview/lldriverparam.cpp b/indra/newview/lldriverparam.cpp index 55b3ab796..7fcfa5504 100644 --- a/indra/newview/lldriverparam.cpp +++ b/indra/newview/lldriverparam.cpp @@ -349,6 +349,12 @@ const LLVector3* LLDriverParam::getNextDistortion(U32 *index, LLPolyMesh **poly_ } } + llassert(driven); + if (!driven) + { + return NULL; // shouldn't happen, but... + } + // We're already in the middle of a param's distortions, so get the next one. const LLVector3* v = driven->mParam->getNextDistortion( index, poly_mesh ); if( (!v) && (iter != mDriven.end()) ) diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp index fd475ef83..8648eef7c 100644 --- a/indra/newview/llfilepicker.cpp +++ b/indra/newview/llfilepicker.cpp @@ -395,9 +395,9 @@ BOOL LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename) { wcsncpy( mFilesW,L"untitled.jpeg", FILENAME_BUFFER_SIZE); /*Flawfinder: ignore*/ } - mOFN.lpstrDefExt = L"jpeg"; + mOFN.lpstrDefExt = L"jpg"; mOFN.lpstrFilter = - L"JPEG Images (*.jpeg)\0*.jpeg\0" \ + L"JPEG Images (*.jpg *.jpeg)\0*.jpg;*.jpeg\0" \ L"\0"; break; case FFSAVE_AVI: diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp index 8f2c6d538..daf5d2a0f 100644 --- a/indra/newview/llflexibleobject.cpp +++ b/indra/newview/llflexibleobject.cpp @@ -67,6 +67,7 @@ LLVolumeImplFlexible::LLVolumeImplFlexible(LLViewerObject* vo, LLFlexibleObjectD mInitializedRes = -1; mSimulateRes = 0; mFrameNum = 0; + mCollisionSphereRadius = 0.f; mRenderRes = 1; if(mVO->mDrawable.notNull()) diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp index aed12d956..5878a8b48 100644 --- a/indra/newview/llgesturemgr.cpp +++ b/indra/newview/llgesturemgr.cpp @@ -1115,12 +1115,11 @@ void LLGestureManager::notifyObservers() { lldebugs << "LLGestureManager::notifyObservers" << llendl; - std::vector observers = mObservers; - - std::vector::iterator it; - for (it = observers.begin(); it != observers.end(); ++it) + for(std::vector::iterator iter = mObservers.begin(); + iter != mObservers.end(); + ++iter) { - LLGestureManagerObserver* observer = *it; + LLGestureManagerObserver* observer = (*iter); observer->changed(); } } diff --git a/indra/newview/llhudeffecttrail.cpp b/indra/newview/llhudeffecttrail.cpp index 08f4c78f1..c01222ebc 100644 --- a/indra/newview/llhudeffecttrail.cpp +++ b/indra/newview/llhudeffecttrail.cpp @@ -121,7 +121,7 @@ void LLHUDEffectSpiral::unpackData(LLMessageSystem *mesgsys, S32 blocknum) LLHUDEffect::unpackData(mesgsys, blocknum); LLUUID object_id, target_object_id; - S32 size = mesgsys->getSizeFast(_PREHASH_Effect, blocknum, _PREHASH_TypeData); + size_t size = mesgsys->getSizeFast(_PREHASH_Effect, blocknum, _PREHASH_TypeData); if (size != EFFECT_SIZE) { llwarns << "Spiral effect with bad size " << size << llendl; diff --git a/indra/newview/llhudrender.cpp b/indra/newview/llhudrender.cpp index 95b8442ec..2f1a653f5 100644 --- a/indra/newview/llhudrender.cpp +++ b/indra/newview/llhudrender.cpp @@ -62,11 +62,12 @@ void hud_render_text(const LLWString &wstr, const LLVector3 &pos_agent, const LLColor4& color, const BOOL orthographic) { + LLViewerCamera* camera = LLViewerCamera::getInstance(); // Do cheap plane culling - LLVector3 dir_vec = pos_agent - LLViewerCamera::getInstance()->getOrigin(); + LLVector3 dir_vec = pos_agent - camera->getOrigin(); dir_vec /= dir_vec.magVec(); - if (wstr.empty() || (!orthographic && dir_vec * LLViewerCamera::getInstance()->getAtAxis() <= 0.f)) + if (wstr.empty() || (!orthographic && dir_vec * camera->getAtAxis() <= 0.f)) { return; } @@ -80,15 +81,15 @@ void hud_render_text(const LLWString &wstr, const LLVector3 &pos_agent, } else { - LLViewerCamera::getInstance()->getPixelVectors(pos_agent, up_axis, right_axis); + camera->getPixelVectors(pos_agent, up_axis, right_axis); } - LLCoordFrame render_frame = *LLViewerCamera::getInstance(); + LLCoordFrame render_frame = *camera; LLQuaternion rot; if (!orthographic) { rot = render_frame.getQuaternion(); - rot = rot * LLQuaternion(-F_PI_BY_TWO, LLViewerCamera::getInstance()->getYAxis()); - rot = rot * LLQuaternion(F_PI_BY_TWO, LLViewerCamera::getInstance()->getXAxis()); + rot = rot * LLQuaternion(-F_PI_BY_TWO, camera->getYAxis()); + rot = rot * LLQuaternion(F_PI_BY_TWO, camera->getXAxis()); } else { diff --git a/indra/newview/llmanip.cpp b/indra/newview/llmanip.cpp index 2ba196273..befc7177b 100644 --- a/indra/newview/llmanip.cpp +++ b/indra/newview/llmanip.cpp @@ -512,10 +512,11 @@ void LLManip::renderXYZ(const LLVector3 &vec) const S32 PAD = 10; std::string feedback_string; LLVector3 camera_pos = LLViewerCamera::getInstance()->getOrigin() + LLViewerCamera::getInstance()->getAtAxis(); - S32 vertical_offset = gViewerWindow->getWindowHeight() / 2 - VERTICAL_OFFSET; S32 window_center_x = gViewerWindow->getWindowWidth() / 2; S32 window_center_y = gViewerWindow->getWindowHeight() / 2; - + S32 vertical_offset = window_center_y - VERTICAL_OFFSET; + + glPushMatrix(); { LLUIImagePtr imagep = LLUI::getUIImage("rounded_square.tga"); @@ -536,29 +537,30 @@ void LLManip::renderXYZ(const LLVector3 &vec) gViewerWindow->setup3DRender(); { + const LLFontGL* font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ); LLLocale locale(LLLocale::USER_LOCALE); LLGLDepthTest gls_depth(GL_FALSE); // render drop shadowed text feedback_string = llformat("X: %.3f", vec.mV[VX]); - hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, -102.f + 1.f, (F32)vertical_offset - 1.f, LLColor4::black, FALSE); + hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *font, LLFontGL::NORMAL, -102.f + 1.f, (F32)vertical_offset - 1.f, LLColor4::black, FALSE); feedback_string = llformat("Y: %.3f", vec.mV[VY]); - hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, -27.f + 1.f, (F32)vertical_offset - 1.f, LLColor4::black, FALSE); + hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *font, LLFontGL::NORMAL, -27.f + 1.f, (F32)vertical_offset - 1.f, LLColor4::black, FALSE); feedback_string = llformat("Z: %.3f", vec.mV[VZ]); - hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, 48.f + 1.f, (F32)vertical_offset - 1.f, LLColor4::black, FALSE); + hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *font, LLFontGL::NORMAL, 48.f + 1.f, (F32)vertical_offset - 1.f, LLColor4::black, FALSE); // render text on top feedback_string = llformat("X: %.3f", vec.mV[VX]); - hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, -102.f, (F32)vertical_offset, LLColor4(1.f, 0.5f, 0.5f, 1.f), FALSE); + hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *font, LLFontGL::NORMAL, -102.f, (F32)vertical_offset, LLColor4(1.f, 0.5f, 0.5f, 1.f), FALSE); glColor3f(0.5f, 1.f, 0.5f); feedback_string = llformat("Y: %.3f", vec.mV[VY]); - hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, -27.f, (F32)vertical_offset, LLColor4(0.5f, 1.f, 0.5f, 1.f), FALSE); + hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *font, LLFontGL::NORMAL, -27.f, (F32)vertical_offset, LLColor4(0.5f, 1.f, 0.5f, 1.f), FALSE); glColor3f(0.5f, 0.5f, 1.f); feedback_string = llformat("Z: %.3f", vec.mV[VZ]); - hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF ), LLFontGL::NORMAL, 48.f, (F32)vertical_offset, LLColor4(0.5f, 0.5f, 1.f, 1.f), FALSE); + hud_render_text(utf8str_to_wstring(feedback_string), camera_pos, *font, LLFontGL::NORMAL, 48.f, (F32)vertical_offset, LLColor4(0.5f, 0.5f, 1.f, 1.f), FALSE); } } diff --git a/indra/newview/llmanipscale.cpp b/indra/newview/llmanipscale.cpp index 47976323e..eb467f921 100644 --- a/indra/newview/llmanipscale.cpp +++ b/indra/newview/llmanipscale.cpp @@ -180,6 +180,7 @@ LLManipScale::LLManipScale( LLToolComposite* composite ) mScaleSnapUnit2(1.f), mSnapRegimeOffset(0.f), mSnapGuideLength(0.f), + mInSnapRegime(FALSE), mScaleSnapValue(0.f) { mManipulatorScales = new F32[NUM_MANIPULATORS]; diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index a3d790f26..20732d9e2 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -276,9 +276,12 @@ void LLPanelFace::sendAlpha() void LLPanelFace::sendGlow() { LLSpinCtrl* mCtrlGlow = getChild("glow"); - F32 glow = mCtrlGlow->get(); - - LLSelectMgr::getInstance()->selectionSetGlow( glow ); + llassert(mCtrlGlow); + if (mCtrlGlow) + { + F32 glow = mCtrlGlow->get(); + LLSelectMgr::getInstance()->selectionSetGlow( glow ); + } } struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor @@ -296,6 +299,8 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor LLCheckBoxCtrl* checkFlipScaleS = mPanel->getChild("checkbox flip s"); LLCheckBoxCtrl* checkFlipScaleT = mPanel->getChild("checkbox flip t"); LLComboBox* comboTexGen = mPanel->getChild("combobox texgen"); + llassert(comboTexGen); + llassert(object); if (ctrlTexScaleS) { valid = !ctrlTexScaleS->getTentative() || !checkFlipScaleS->getTentative(); @@ -306,7 +311,8 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor { value = -value; } - if (comboTexGen->getCurrentIndex() == 1) + if (comboTexGen && + comboTexGen->getCurrentIndex() == 1) { value *= 0.5f; } @@ -324,7 +330,8 @@ struct LLPanelFaceSetTEFunctor : public LLSelectedTEFunctor { value = -value; } - if (comboTexGen->getCurrentIndex() == 1) + if (comboTexGen && + comboTexGen->getCurrentIndex() == 1) { value *= 0.5f; } diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 08fc6eb5d..ff6bba3b3 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -975,7 +975,10 @@ void LLVOSky::calcAtmospherics(void) } temp2.mV[1] = llmax(0.f, lighty); - temp2.mV[1] = 1.f / temp2.mV[1]; + if(temp2.mV[1] > 0.f) + { + temp2.mV[1] = 1.f / temp2.mV[1]; + } componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); // Distance diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index b9b4a2ca8..80a70565e 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -123,6 +123,7 @@ LLWorld::LLWorld() : void LLWorld::destroyClass() { + mHoleWaterObjects.clear(); gObjectList.destroy(); for(region_list_t::iterator region_it = mRegionList.begin(); region_it != mRegionList.end(); ) { @@ -263,6 +264,7 @@ void LLWorld::removeRegion(const LLHost &host) llwarns << "Disabling region " << regionp->getName() << " that agent is in!" << llendl; LLAppViewer::instance()->forceDisconnect("You have been disconnected from the region you were in."); + return; }