From 12d2bf47865559a8da087f6e3bbb4b65d421169c Mon Sep 17 00:00:00 2001
From: Mnikolenko ProductEngine <mnikolenko@productengine.com>
Date: Wed, 18 Nov 2020 21:09:57 +0200
Subject: [PATCH] SL-14286 fixed crash when closing viewer while file picker is
 open

---
 indra/newview/llappdelegate-objc.mm     | 1 +
 indra/newview/llfloatermodelpreview.cpp | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm
index a2b7362608d..3f1b5139c5c 100644
--- a/indra/newview/llappdelegate-objc.mm
+++ b/indra/newview/llappdelegate-objc.mm
@@ -134,6 +134,7 @@
 		// called again. Since it returned false, do not yet cancel
 		// frameTimer.
 		handleQuit();
+		[[NSApplication sharedApplication] stopModal];
 		return NSTerminateCancel;
 	} else {
 		// pumpMainLoop() returned true: it's done. Okay, done with frameTimer.
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index b9c03f66a3e..999e4a9582f 100644
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -103,6 +103,11 @@ LLMeshFilePicker::LLMeshFilePicker(LLModelPreview* mp, S32 lod)
 
 void LLMeshFilePicker::notify(const std::vector<std::string>& filenames)
 {
+	if(LLAppViewer::instance()->quitRequested())
+	{
+		return;
+	}
+	
 	if (filenames.size() > 0)
 	{
 		mMP->loadModel(filenames[0], mLOD);
-- 
GitLab