From 250a0396ac2c8af0a8139b50b55c81f036d37def Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Tue, 22 May 2018 14:24:09 +0300
Subject: [PATCH] MAINT-8635 Don't allow using 'close all windows' if modal
 toast is open

---
 indra/newview/lltoast.cpp          | 15 +++++++++++++++
 indra/newview/lltoast.h            |  4 ++++
 indra/newview/llviewermenufile.cpp |  5 +++--
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/indra/newview/lltoast.cpp b/indra/newview/lltoast.cpp
index edde7c8076c..b9b05966bc9 100644
--- a/indra/newview/lltoast.cpp
+++ b/indra/newview/lltoast.cpp
@@ -34,6 +34,7 @@
 #include "llviewercontrol.h"
 
 using namespace LLNotificationsUI;
+std::list<LLToast*> LLToast::sModalToastsList;
 
 //--------------------------------------------------------------------------
 LLToastLifeTimer::LLToastLifeTimer(LLToast* toast, F32 period)
@@ -143,6 +144,11 @@ LLToast::LLToast(const LLToast::Params& p)
 	{
 		mOnDeleteToastSignal.connect(p.on_delete_toast());
 	}
+
+	if (isModal())
+	{
+		sModalToastsList.push_front(this);
+	}
 }
 
 void LLToast::reshape(S32 width, S32 height, BOOL called_from_parent)
@@ -187,6 +193,15 @@ LLToast::~LLToast()
 	{
 		mOnToastDestroyedSignal(this);
 	}
+
+	if (isModal())
+	{
+		std::list<LLToast*>::iterator iter = std::find(sModalToastsList.begin(), sModalToastsList.end(), this);
+		if (iter != sModalToastsList.end())
+		{
+			sModalToastsList.erase(iter);
+		}
+	}
 }
 
 //--------------------------------------------------------------------------
diff --git a/indra/newview/lltoast.h b/indra/newview/lltoast.h
index cd92189012d..69074b16705 100644
--- a/indra/newview/lltoast.h
+++ b/indra/newview/lltoast.h
@@ -108,6 +108,8 @@ class LLToast : public LLModalDialog, public LLInstanceTracker<LLToast>
 	static void updateClass();
 	static void cleanupToasts();
 
+	static BOOL isAlertToastShown() { return sModalToastsList.size() > 0; }
+
 	LLToast(const LLToast::Params& p);
 	virtual ~LLToast();
 	BOOL postBuild();
@@ -245,6 +247,8 @@ class LLToast : public LLModalDialog, public LLInstanceTracker<LLToast>
 
 	commit_signal_t mToastMouseEnterSignal;
 	commit_signal_t mToastMouseLeaveSignal;
+
+	static std::list<LLToast*> sModalToastsList;
 };
 
 }
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 90355b7166e..e4525609c2f 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -46,6 +46,7 @@
 #include "llimagetga.h"
 #include "llinventorymodel.h"	// gInventory
 #include "llresourcedata.h"
+#include "lltoast.h"
 #include "llfloaterperms.h"
 #include "llstatusbar.h"
 #include "llviewercontrol.h"	// gSavedSettings
@@ -482,7 +483,7 @@ class LLFileEnableCloseWindow : public view_listener_t
 		bool frontmost_fl_exists = (NULL != gFloaterView->getFrontmostClosableFloater());
 		bool frontmost_snapshot_fl_exists = (NULL != gSnapshotFloaterView->getFrontmostClosableFloater());
 
-		return frontmost_fl_exists || frontmost_snapshot_fl_exists;
+		return !LLNotificationsUI::LLToast::isAlertToastShown() && (frontmost_fl_exists || frontmost_snapshot_fl_exists);
 	}
 };
 
@@ -519,7 +520,7 @@ class LLFileEnableCloseAllWindows : public view_listener_t
 		bool is_floaters_snapshot_opened = (floater_snapshot && floater_snapshot->isInVisibleChain())
 			|| (floater_outfit_snapshot && floater_outfit_snapshot->isInVisibleChain());
 		bool open_children = gFloaterView->allChildrenClosed() && !is_floaters_snapshot_opened;
-		return !open_children;
+		return !open_children && !LLNotificationsUI::LLToast::isAlertToastShown();
 	}
 };
 
-- 
GitLab