From 990a821f70ca648bc7d1a58045fdd79f53b61fbd Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Fri, 1 Jul 2011 02:00:58 -0700 Subject: A fix for #995: crashing when changing 'Only my Friends and Groups can see when I am online' --- linden/indra/newview/llfloaterpreference.cpp | 95 ++++++++++++++++++---------- linden/indra/newview/llprefschat.cpp | 25 ++++++-- linden/indra/newview/llprefschat.h | 3 + linden/indra/newview/llprefsim.cpp | 70 ++++++++++++++------ linden/indra/newview/llprefsim.h | 3 + 5 files changed, 138 insertions(+), 58 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/llfloaterpreference.cpp b/linden/indra/newview/llfloaterpreference.cpp index d518eac..301fba0 100644 --- a/linden/indra/newview/llfloaterpreference.cpp +++ b/linden/indra/newview/llfloaterpreference.cpp @@ -303,6 +303,24 @@ void LLPreferenceCore::apply() mLCDPanel->apply(); } #endif + + // Sims always wants us to send IMViaEMail and DirectoryVisible in the same msg or we crash, they're evil like that + // We only know both these values after mPrefsChat and mPrefsIM have been applied -- MC + if (mPrefsChat->getUpdateUserInfo() || mPrefsIM->getUpdateUserInfo()) + { + bool new_im_via_email = mPrefsChat->getIMViaEmail(); + std::string directory_visibility = mPrefsIM->getDirectoryVis(); + + LLMessageSystem* msg = gMessageSystem; + msg->newMessageFast(_PREHASH_UpdateUserInfo); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + msg->nextBlockFast(_PREHASH_UserData); + msg->addBOOLFast(_PREHASH_IMViaEMail, new_im_via_email); + msg->addString("DirectoryVisibility", directory_visibility); + gAgent.sendReliableMessage(); + } } @@ -469,34 +487,37 @@ bool LLFloaterPreference::callbackReset(const LLSD& notification, const LLSD& re void LLFloaterPreference::onBtnOK( void* userdata ) { LLFloaterPreference *fp =(LLFloaterPreference *)userdata; - // commit any outstanding text entry - if (fp->hasFocus()) + if (fp) { - LLUICtrl* cur_focus = dynamic_cast(gFocusMgr.getKeyboardFocus()); - if (cur_focus->acceptsTextInput()) + // commit any outstanding text entry + if (fp->hasFocus()) { - cur_focus->onCommit(); + LLUICtrl* cur_focus = dynamic_cast(gFocusMgr.getKeyboardFocus()); + if (cur_focus->acceptsTextInput()) + { + cur_focus->onCommit(); + } } - } - if (fp->canClose()) - { - fp->apply(); - fp->close(false); + if (fp->canClose()) + { + fp->apply(); + fp->close(false); - gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE ); - - std::string crash_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE); - // save all settings, even if equals defaults - gCrashSettings.saveToFile(crash_settings_filename, FALSE); - } - else - { - // Show beep, pop up dialog, etc. - llinfos << "Can't close preferences!" << llendl; - } + gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE ); + + std::string crash_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE); + // save all settings, even if equals defaults + gCrashSettings.saveToFile(crash_settings_filename, FALSE); + } + else + { + // Show beep, pop up dialog, etc. + llinfos << "Can't close preferences!" << llendl; + } - LLPanelLogin::refreshLocation( false ); + LLPanelLogin::refreshLocation( false ); + } } @@ -504,17 +525,20 @@ void LLFloaterPreference::onBtnOK( void* userdata ) void LLFloaterPreference::onBtnApply( void* userdata ) { LLFloaterPreference *fp =(LLFloaterPreference *)userdata; - if (fp->hasFocus()) + if (fp) { - LLUICtrl* cur_focus = dynamic_cast(gFocusMgr.getKeyboardFocus()); - if (cur_focus->acceptsTextInput()) + if (fp->hasFocus()) { - cur_focus->onCommit(); + LLUICtrl* cur_focus = dynamic_cast(gFocusMgr.getKeyboardFocus()); + if (cur_focus->acceptsTextInput()) + { + cur_focus->onCommit(); + } } - } - fp->apply(); + fp->apply(); - LLPanelLogin::refreshLocation( false ); + LLPanelLogin::refreshLocation( false ); + } } @@ -530,15 +554,18 @@ void LLFloaterPreference::onClose(bool app_quitting) void LLFloaterPreference::onBtnCancel( void* userdata ) { LLFloaterPreference *fp =(LLFloaterPreference *)userdata; - if (fp->hasFocus()) + if (fp) { - LLUICtrl* cur_focus = dynamic_cast(gFocusMgr.getKeyboardFocus()); - if (cur_focus->acceptsTextInput()) + if (fp->hasFocus()) { - cur_focus->onCommit(); + LLUICtrl* cur_focus = dynamic_cast(gFocusMgr.getKeyboardFocus()); + if (cur_focus->acceptsTextInput()) + { + cur_focus->onCommit(); + } } + fp->close(); // side effect will also cancel any unsaved changes. } - fp->close(); // side effect will also cancel any unsaved changes. } diff --git a/linden/indra/newview/llprefschat.cpp b/linden/indra/newview/llprefschat.cpp index 9490ba2..1cdab46 100644 --- a/linden/indra/newview/llprefschat.cpp +++ b/linden/indra/newview/llprefschat.cpp @@ -46,7 +46,6 @@ #include "lggautocorrectfloater.h" #include "llprefschat.h" #include "llviewercontrol.h" -#include "llviewermessage.h" class LLPrefsChatImpl : public LLPanel { @@ -72,8 +71,10 @@ public: static void onSpellEditCustom(void* data); static void onSpellBaseComboBoxCommit(LLUICtrl* ctrl, void* userdata); -protected: + bool mUpdateUserInfo; bool mOriginalIMViaEmail; + +protected: bool mGotPersonalInfo; private: @@ -84,7 +85,8 @@ LLPrefsChatImpl::LLPrefsChatImpl() : LLPanel(std::string("Chat Panel")), mChatChannel(false), mOriginalIMViaEmail(false), - mGotPersonalInfo(false) + mGotPersonalInfo(false), + mUpdateUserInfo(false) { LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_chat.xml"); } @@ -230,14 +232,17 @@ void LLPrefsChatImpl::apply() if (new_im_via_email != mOriginalIMViaEmail) { - LLMessageSystem* msg = gMessageSystem; + mOriginalIMViaEmail = new_im_via_email; + mUpdateUserInfo = true; + + /*LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_UpdateUserInfo); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_UserData); msg->addBOOLFast(_PREHASH_IMViaEMail, new_im_via_email); - gAgent.sendReliableMessage(); + gAgent.sendReliableMessage();*/ } } @@ -379,6 +384,16 @@ void LLPrefsChat::setPersonalInfo(bool im_via_email, const std::string& email) impl.setPersonalInfo(im_via_email, email); } +bool LLPrefsChat::getUpdateUserInfo() +{ + return impl.mUpdateUserInfo; +} + +bool LLPrefsChat::getIMViaEmail() +{ + return impl.mOriginalIMViaEmail; +} + LLPanel* LLPrefsChat::getPanel() { return &impl; diff --git a/linden/indra/newview/llprefschat.h b/linden/indra/newview/llprefschat.h index 64bfb36..6c69a2b 100644 --- a/linden/indra/newview/llprefschat.h +++ b/linden/indra/newview/llprefschat.h @@ -48,6 +48,9 @@ public: LLPanel* getPanel(); + bool getUpdateUserInfo(); + bool getIMViaEmail(); + protected: LLPrefsChatImpl& impl; }; diff --git a/linden/indra/newview/llprefsim.cpp b/linden/indra/newview/llprefsim.cpp index 47b5d8b..e037ac7 100644 --- a/linden/indra/newview/llprefsim.cpp +++ b/linden/indra/newview/llprefsim.cpp @@ -74,13 +74,15 @@ public: static void onClickBusyAdvanced(void* user_data); + bool mUpdateUserInfo; + std::string mDirectoryVisibility; + protected: bool mGotPersonalInfo; bool mGotPerAccountSettings; bool mOriginalHideOnlineStatus; - std::string mDirectoryVisibility; }; @@ -88,7 +90,9 @@ LLPrefsIMImpl::LLPrefsIMImpl() : LLPanel(std::string("IM Prefs Panel")), mGotPersonalInfo(false), mGotPerAccountSettings(false), - mOriginalHideOnlineStatus(false) + mOriginalHideOnlineStatus(false), + mDirectoryVisibility(""), + mUpdateUserInfo(false) { LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_im.xml"); } @@ -178,27 +182,45 @@ void LLPrefsIMImpl::apply() if (new_hide_online != mOriginalHideOnlineStatus) { - LLMessageSystem* msg = gMessageSystem; - msg->newMessageFast(_PREHASH_UpdateUserInfo); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - msg->nextBlockFast(_PREHASH_UserData); - //msg->addBOOLFast(_PREHASH_IMViaEMail, new_im_via_email); + mOriginalHideOnlineStatus = new_hide_online; + // This hack is because we are representing several different // possible strings with a single checkbox. Since most users // can only select between 2 values, we represent it as a // checkbox. This breaks down a little bit for liaisons, but - // works out in the end. - if(new_hide_online != mOriginalHideOnlineStatus) - { - if(new_hide_online) mDirectoryVisibility = VISIBILITY_HIDDEN; - else mDirectoryVisibility = VISIBILITY_DEFAULT; - //Update showonline value, otherwise multiple applys won't work - mOriginalHideOnlineStatus = new_hide_online; - } - msg->addString("DirectoryVisibility", mDirectoryVisibility); - gAgent.sendReliableMessage(); + // works out in the end. + if (new_hide_online) + { + mDirectoryVisibility = VISIBILITY_HIDDEN; + } + else + { + mDirectoryVisibility = VISIBILITY_DEFAULT; + } + + mUpdateUserInfo = true; + + //LLMessageSystem* msg = gMessageSystem; + //msg->newMessageFast(_PREHASH_UpdateUserInfo); + //msg->nextBlockFast(_PREHASH_AgentData); + //msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + //msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + //msg->nextBlockFast(_PREHASH_UserData); + ////msg->addBOOLFast(_PREHASH_IMViaEMail, new_im_via_email); + //// This hack is because we are representing several different + //// possible strings with a single checkbox. Since most users + //// can only select between 2 values, we represent it as a + //// checkbox. This breaks down a little bit for liaisons, but + //// works out in the end. + //if(new_hide_online != mOriginalHideOnlineStatus) + //{ + // if(new_hide_online) mDirectoryVisibility = VISIBILITY_HIDDEN; + // else mDirectoryVisibility = VISIBILITY_DEFAULT; + // //Update showonline value, otherwise multiple applys won't work + // mOriginalHideOnlineStatus = new_hide_online; + //} + //msg->addString("DirectoryVisibility", mDirectoryVisibility); + //gAgent.sendReliableMessage(); } } } @@ -341,6 +363,16 @@ void LLPrefsIM::preparePerAccountPrefs(bool enable) impl.preparePerAccountPrefs(enable); } +bool LLPrefsIM::getUpdateUserInfo() +{ + return impl.mUpdateUserInfo; +} + +std::string LLPrefsIM::getDirectoryVis() +{ + return impl.mDirectoryVisibility; +} + LLPanel* LLPrefsIM::getPanel() { return &impl; diff --git a/linden/indra/newview/llprefsim.h b/linden/indra/newview/llprefsim.h index 054e4c7..8003ca2 100644 --- a/linden/indra/newview/llprefsim.h +++ b/linden/indra/newview/llprefsim.h @@ -50,6 +50,9 @@ public: LLPanel* getPanel(); + bool getUpdateUserInfo(); + std::string getDirectoryVis(); + protected: LLPrefsIMImpl& impl; }; -- cgit v1.1