From 4f14dccffaa3b38377ad55486e38e4587a233319 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 19 Feb 2019 16:13:42 -0800 Subject: SL-10570: Additional checking when loading a track from another day cycle. Restore original track if error. Extra messages to user. --- indra/newview/llfloatereditextdaycycle.cpp | 49 +++++++++++++++++++--- .../newview/skins/default/xui/en/notifications.xml | 27 ++++++++++++ 2 files changed, 70 insertions(+), 6 deletions(-) diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index eccdf8249d..482caaaa85 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -587,6 +587,15 @@ BOOL LLFloaterEditExtDayCycle::handleKeyUp(KEY key, MASK mask, BOOL called_from_ void LLFloaterEditExtDayCycle::onButtonApply(LLUICtrl *ctrl, const LLSD &data) { std::string ctrl_action = ctrl->getName(); + + if (!mEditDay) + { + LL_WARNS("ENVDAYEDIT") << "mEditDay is null! This should never happen! Something is very very wrong" << LL_ENDL; + LLNotificationsUtil::add("EnvironmentApplyFailed"); + closeFloater(); + return; + } + LLSettingsDay::ptr_t dayclone = mEditDay->buildClone(); // create a compressed copy if (!dayclone) @@ -1078,22 +1087,50 @@ void LLFloaterEditExtDayCycle::cloneTrack(U32 source_index, U32 dest_index) void LLFloaterEditExtDayCycle::cloneTrack(const LLSettingsDay::ptr_t &source_day, U32 source_index, U32 dest_index) { - if (source_index == LLSettingsDay::TRACK_WATER || dest_index == LLSettingsDay::TRACK_WATER) - { - LL_WARNS() << "water track can't be source or destination for copying" << LL_ENDL; + if ((source_index == LLSettingsDay::TRACK_WATER || dest_index == LLSettingsDay::TRACK_WATER) && (source_index != dest_index)) + { // one of the tracks is a water track, the other is not + LLSD args; + + LL_WARNS() << "Can not import water track into sky track or vice versa" << LL_ENDL; + + LLButton* button = getChild(track_tabs[source_index], true); + args["TRACK1"] = button->getCurrentLabel(); + button = getChild(track_tabs[dest_index], true); + args["TRACK2"] = button->getCurrentLabel(); + + LLNotificationsUtil::add("TrackLoadMismatch", args); return; } // don't use replaceCycleTrack because we will end up with references, but we need to clone + + // hold on to a backup of the + LLSettingsDay::CycleTrack_t backup_track = mEditDay->getCycleTrack(dest_index); + mEditDay->clearCycleTrack(dest_index); // because source can be empty LLSettingsDay::CycleTrack_t source_track = source_day->getCycleTrack(source_index); - + S32 addcount(0); for (auto &track_frame : source_track) { - LLSettingsSky::ptr_t psky = std::static_pointer_cast(track_frame.second); - mEditDay->setSettingsAtKeyframe(psky->buildDerivedClone(), track_frame.first, dest_index); + LLSettingsBase::ptr_t pframe = track_frame.second; + LLSettingsBase::ptr_t pframeclone = pframe->buildDerivedClone(); + if (pframeclone) + { + ++addcount; + mEditDay->setSettingsAtKeyframe(pframeclone, track_frame.first, dest_index); + } } + if (!addcount) + { // nothing was actually added. Restore the old track and issue a warning. + mEditDay->replaceCycleTrack(dest_index, backup_track); + + LLSD args; + LLButton* button = getChild(track_tabs[dest_index], true); + args["TRACK"] = button->getCurrentLabel(); + + LLNotificationsUtil::add("TrackLoadFailed", args); + } setDirtyFlag(); updateSlider(); diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index dfc392e1f7..5ed3bd5df5 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -11347,5 +11347,32 @@ You may not edit settings directly from the libary. Please copy to your own inventory and try again. fail + + +We have encountered an issue with these settings. They can not be saved or applied at this time. + fail + + + +Unable to load the track into [TRACK]. + fail + + + +Unable to load the track from [TRACK1] into [TRACK2]. + fail + -- cgit v1.2.3