diff options
author | Mark Palange <palange@lindenlab.com> | 2009-01-13 03:46:56 +0000 |
---|---|---|
committer | Mark Palange <palange@lindenlab.com> | 2009-01-13 03:46:56 +0000 |
commit | 446c55538e1fb12d8a1feb541edf99c16bb29121 (patch) | |
tree | 022ca3c10bd2e0326098719cdffb65f9465ab08f /indra/newview/llappviewermacosx.cpp | |
parent | 5476aca88e4b34d4d145f3a0b04fce95402c7b1f (diff) |
svn merge -r106055-107012 svn+ssh://svn.lindenlab.com/svn/linden/branches/viewer/viewer_1-22/
merge RC5 changes into trunk, plus add'l localization xml (all newly added) files that should have been added with RC0-RC4 merge, but weren't.
Diffstat (limited to 'indra/newview/llappviewermacosx.cpp')
-rw-r--r-- | indra/newview/llappviewermacosx.cpp | 107 |
1 files changed, 96 insertions, 11 deletions
diff --git a/indra/newview/llappviewermacosx.cpp b/indra/newview/llappviewermacosx.cpp index 67aeef8b12..3cdcb35197 100644 --- a/indra/newview/llappviewermacosx.cpp +++ b/indra/newview/llappviewermacosx.cpp @@ -58,6 +58,17 @@ namespace // They are not used immediately by the app. int gArgC; char** gArgV; + + bool sCrashReporterIsRunning = false; + + OSErr AEQuitHandler(const AppleEvent *messagein, AppleEvent *reply, long refIn) + { + OSErr result = noErr; + + LLAppViewer::instance()->userQuit(); + + return(result); + } } int main( int argc, char **argv ) @@ -259,8 +270,37 @@ void LLAppViewerMacOSX::handleSyncCrashTrace() // do nothing } +static OSStatus CarbonEventHandler(EventHandlerCallRef inHandlerCallRef, + EventRef inEvent, + void* inUserData) +{ + ProcessSerialNumber psn; + + GetEventParameter(inEvent, + kEventParamProcessID, + typeProcessSerialNumber, + NULL, + sizeof(psn), + NULL, + &psn); + + if( GetEventKind(inEvent) == kEventAppTerminated ) + { + Boolean matching_psn = FALSE; + OSErr os_result = SameProcess(&psn, (ProcessSerialNumber*)inUserData, &matching_psn); + if(os_result >= 0 && matching_psn) + { + sCrashReporterIsRunning = false; + } + } + return noErr; +} + void LLAppViewerMacOSX::handleCrashReporting(bool reportFreeze) { + // This used to use fork&exec, but is switched to LSOpenApplication to + // Make sure the crash reporter launches in front of the SL window. + std::string command_str; //command_str = "open Second Life.app/Contents/Resources/mac-crash-logger.app"; command_str = "mac-crash-logger.app/Contents/MacOS/mac-crash-logger"; @@ -282,15 +322,69 @@ void LLAppViewerMacOSX::handleCrashReporting(bool reportFreeze) { // Make sure freeze reporting launches the crash logger synchronously, lest // Log files get changed by SL while the logger is running. + + // *NOTE:Mani A better way - make a copy of the data that the crash reporter will send + // and let SL go about its business. This way makes the mac work like windows and linux + // and is the smallest patch for the issue. + sCrashReporterIsRunning = true; + ProcessSerialNumber o_psn; + + static EventHandlerRef sCarbonEventsRef = NULL; + static const EventTypeSpec kEvents[] = + { + { kEventClassApplication, kEventAppTerminated } + }; + + // Install the handler to detect crash logger termination + InstallEventHandler(GetApplicationEventTarget(), + (EventHandlerUPP) CarbonEventHandler, + GetEventTypeCount(kEvents), + kEvents, + &o_psn, + &sCarbonEventsRef + ); + + // Remove, temporarily the quit handler - which has *crash* behavior before + // the mainloop gets running! + AERemoveEventHandler(kCoreEventClass, + kAEQuitApplication, + NewAEEventHandlerUPP(AEQuitHandler), + false); + + // Launch the crash reporter. + os_result = LSOpenApplication(&appParams, &o_psn); + + if(os_result >= 0) + { + EventRecord evt; + while(sCrashReporterIsRunning) + { + while(WaitNextEvent(osMask, &evt, 0, NULL)) + { + // null op!?! + } + } + } + + // Re-install the apps quit handler. + AEInstallEventHandler(kCoreEventClass, + kAEQuitApplication, + NewAEEventHandlerUPP(AEQuitHandler), + 0, + false); + + // Remove the crash reporter quit handler. + RemoveEventHandler(sCarbonEventsRef); } else { appParams.flags |= kLSLaunchAsync; clear_signals(); + + ProcessSerialNumber o_psn; + os_result = LSOpenApplication(&appParams, &o_psn); } - ProcessSerialNumber o_psn; - os_result = LSOpenApplication(&appParams, &o_psn); } if(!reportFreeze) @@ -368,15 +462,6 @@ OSErr AEGURLHandler(const AppleEvent *messagein, AppleEvent *reply, long refIn) return(result); } -OSErr AEQuitHandler(const AppleEvent *messagein, AppleEvent *reply, long refIn) -{ - OSErr result = noErr; - - LLAppViewer::instance()->userQuit(); - - return(result); -} - OSStatus simpleDialogHandler(EventHandlerCallRef handler, EventRef event, void *userdata) { OSStatus result = eventNotHandledErr; |