diff --git a/indra/llui/llmodaldialog.cpp b/indra/llui/llmodaldialog.cpp index 9996ca460..8c8f94113 100644 --- a/indra/llui/llmodaldialog.cpp +++ b/indra/llui/llmodaldialog.cpp @@ -69,6 +69,12 @@ LLModalDialog::~LLModalDialog() { gFocusMgr.unlockFocus(); } + + std::list::iterator iter = std::find(sModalStack.begin(), sModalStack.end(), this); + if (iter != sModalStack.end()) + { + llerrs << "Attempt to delete dialog while still in sModalStack!" << llendl; + } } // virtual @@ -91,6 +97,8 @@ void LLModalDialog::startModal() { if (mModal) { + + // If Modal, Hide the active modal dialog if (!sModalStack.empty()) { @@ -103,6 +111,14 @@ void LLModalDialog::startModal() gFocusMgr.setTopCtrl( this ); setFocus(TRUE); + std::list::iterator iter = std::find(sModalStack.begin(), sModalStack.end(), this); + if (iter != sModalStack.end()) + { + sModalStack.erase(iter); + llwarns << "Dialog already on modal stack" << llendl; + //TODO: incvestigate in which specific cases it happens, cause that's not good! -SG + } + sModalStack.push_front( this ); } @@ -314,5 +330,16 @@ void LLModalDialog::onAppFocusGained() } } - - +void LLModalDialog::shutdownModals() +{ + // This method is only for use during app shutdown. ~LLModalDialog() + // checks sModalStack, and if the dialog instance is still there, it + // crumps with "Attempt to delete dialog while still in sModalStack!" But + // at app shutdown, all bets are off. If the user asks to shut down the + // app, we shouldn't have to care WHAT's open. Put differently, if a modal + // dialog is so crucial that we can't let the user terminate until s/he + // addresses it, we should reject a termination request. The current state + // of affairs is that we accept it, but then produce an llerrs popup that + // simply makes our software look unreliable. + sModalStack.clear(); +} diff --git a/indra/llui/llmodaldialog.h b/indra/llui/llmodaldialog.h index f6abd0a7a..09f9f197e 100644 --- a/indra/llui/llmodaldialog.h +++ b/indra/llui/llmodaldialog.h @@ -74,7 +74,8 @@ public: static void onAppFocusGained(); static S32 activeCount() { return sModalStack.size(); } - + static void shutdownModals(); + protected: void centerOnScreen(); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 9a2626301..1c4bdfcff 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2033,7 +2033,11 @@ void LLViewerWindow::shutdownViews() { gMorphView->setVisible(FALSE); } - + + // DEV-40930: Clear sModalStack. Otherwise, any LLModalDialog left open + // will crump with LL_ERRS. + LLModalDialog::shutdownModals(); + // Delete all child views. delete mRootView; mRootView = NULL;