From 966a4c893c816fc699580092bd6e93a0e514798c Mon Sep 17 00:00:00 2001
From: Geenz <geenz@geenzo.com>
Date: Wed, 2 Jan 2013 16:16:07 -0500
Subject: [PATCH] OS X crash on startup fix: always ensure that
 mMainLoopInitialized is initialized properly within LLAppViewer::init(). 
 Otherwise, the viewer will sporadically crash on start up.

---
 indra/newview/llappviewer.cpp | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 6a87f7306d9..131f4c40315 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -676,6 +676,11 @@ bool LLAppViewer::init()
 	// we run the "program crashed last time" error handler below.
 	//
 	LLFastTimer::reset();
+	
+	
+#ifdef LL_DARWIN
+	mMainLoopInitialized = false;
+#endif
 
 	// initialize SSE options
 	LLVector4a::initClass();
@@ -1196,7 +1201,9 @@ LLMemType mt1(LLMemType::MTYPE_MAIN);
 
 bool LLAppViewer::mainLoop()
 {
+#ifdef LL_DARWIN
 	if (!mMainLoopInitialized)
+#endif
 	{
 		mMainloopTimeout = new LLWatchdogTimeout();
 		
@@ -1218,13 +1225,16 @@ bool LLAppViewer::mainLoop()
 		joystick = LLViewerJoystick::getInstance();
 		joystick->setNeedsReset(true);
 		
-		
-		// As we do not (yet) send data on the mainloop LLEventPump that varies
-		// with each frame, no need to instantiate a new LLSD event object each
-		// time. Obviously, if that changes, just instantiate the LLSD at the
-		// point of posting.
+#ifdef LL_DARWIN
+		// Ensure that this section of code never gets called again on OS X.
 		mMainLoopInitialized = true;
+#endif
 	}
+	// As we do not (yet) send data on the mainloop LLEventPump that varies
+	// with each frame, no need to instantiate a new LLSD event object each
+	// time. Obviously, if that changes, just instantiate the LLSD at the
+	// point of posting.
+	
 	LLEventPump& mainloop(LLEventPumps::instance().obtain("mainloop"));
 	
     LLSD newFrame;
-- 
GitLab