From 1f9a6f3bdcadb11aea5083e3066ef5e870e69f8a Mon Sep 17 00:00:00 2001
From: brad kittenbrink <brad@lindenlab.com>
Date: Tue, 7 Jul 2009 18:09:45 -0700
Subject: [PATCH] Fix for crash when quitting due to mAppViewer being NULL.

---
 indra/newview/llappviewer.cpp         | 2 +-
 indra/newview/llappviewerlistener.cpp | 6 +++++-
 indra/newview/llappviewerlistener.h   | 2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index bed63c4dbce..b14853777d7 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -188,7 +188,7 @@
 // define a self-registering event API object
 #include "llappviewerlistener.h"
 
-static LLAppViewerListener sAppViewerListener("LLAppViewer", LLAppViewer::instance());
+static LLAppViewerListener sAppViewerListener("LLAppViewer", NULL);
 
 ////// Windows-specific includes to the bottom - nasty defines in these pollute the preprocessor
 //
diff --git a/indra/newview/llappviewerlistener.cpp b/indra/newview/llappviewerlistener.cpp
index a8c98b17a73..a3af251a3c3 100644
--- a/indra/newview/llappviewerlistener.cpp
+++ b/indra/newview/llappviewerlistener.cpp
@@ -27,7 +27,11 @@ LLAppViewerListener::LLAppViewerListener(const std::string& pumpname, LLAppViewe
     add("requestQuit", &LLAppViewerListener::requestQuit);
 }
 
-void LLAppViewerListener::requestQuit(const LLSD& event) const
+void LLAppViewerListener::requestQuit(const LLSD& event)
 {
+    if(mAppViewer == NULL)
+    {
+        mAppViewer = LLAppViewer::instance();
+    }
     mAppViewer->requestQuit();
 }
diff --git a/indra/newview/llappviewerlistener.h b/indra/newview/llappviewerlistener.h
index ab17dd1d904..d702f605ef0 100644
--- a/indra/newview/llappviewerlistener.h
+++ b/indra/newview/llappviewerlistener.h
@@ -26,7 +26,7 @@ class LLAppViewerListener: public LLDispatchListener
     LLAppViewerListener(const std::string& pumpname, LLAppViewer* llappviewer);
 
 private:
-    void requestQuit(const LLSD& event) const;
+    void requestQuit(const LLSD& event);
 
     LLAppViewer* mAppViewer;
 };
-- 
GitLab