From 3ebe0489682d43d3c69c9a114facd5cced7f8e94 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Fri, 26 Feb 2010 16:32:49 +0000 Subject: [PATCH] * Fix a memory leak in OS X Sys_Dialog * Fix compilation on Snow Leopard --- Makefile | 2 +- code/qcommon/q_platform.h | 3 +++ code/sys/sys_osx.m | 56 ++++++++++++++++++++++----------------- 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 4332c8ce..8ef1fc11 100644 --- a/Makefile +++ b/Makefile @@ -1113,7 +1113,7 @@ makedirs: # QVM BUILD TOOLS ############################################################################# -TOOLS_OPTIMIZE = -g -O2 -Wall -fno-strict-aliasing +TOOLS_OPTIMIZE = -g -Wall -fno-strict-aliasing TOOLS_CFLAGS += $(TOOLS_OPTIMIZE) \ -DTEMPDIR=\"$(TEMPDIR)\" -DSYSTEM=\"\" \ -I$(Q3LCCSRCDIR) \ diff --git a/code/qcommon/q_platform.h b/code/qcommon/q_platform.h index 021c9c7b..5f498fc5 100644 --- a/code/qcommon/q_platform.h +++ b/code/qcommon/q_platform.h @@ -119,6 +119,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #elif defined __i386__ #define ARCH_STRING "i386" #define Q3_LITTLE_ENDIAN +#elif defined __x86_64__ +#define ARCH_STRING "x86_64" +#define Q3_LITTLE_ENDIAN #endif #define DLL_EXT ".dylib" diff --git a/code/sys/sys_osx.m b/code/sys/sys_osx.m index 237a931e..a26d8a28 100644 --- a/code/sys/sys_osx.m +++ b/code/sys/sys_osx.m @@ -41,19 +41,19 @@ Sys_TempPath */ const char *Sys_TempPath( void ) { - static UInt8 posixPath[ MAX_OSPATH ]; - FSRef ref; - if( FSFindFolder( kOnAppropriateDisk, - kTemporaryFolderType, kCreateFolder, &ref ) == noErr ) - { - if( FSRefMakePath( &ref, posixPath, - sizeof( posixPath ) - 1 ) == noErr ) - { - return (const char *)posixPath; - } - } + static UInt8 posixPath[ MAX_OSPATH ]; + FSRef ref; + if( FSFindFolder( kOnAppropriateDisk, + kTemporaryFolderType, kCreateFolder, &ref ) == noErr ) + { + if( FSRefMakePath( &ref, posixPath, + sizeof( posixPath ) - 1 ) == noErr ) + { + return (const char *)posixPath; + } + } - return "/tmp"; + return "/tmp"; } /* @@ -65,43 +65,51 @@ Display an OS X dialog box */ dialogResult_t Sys_Dialog( dialogType_t type, const char *message, const char *title ) { - NSAlert* alert = [NSAlert new]; - + dialogResult_t result = DR_OK; + NSAlert *alert = [NSAlert new]; + [alert setMessageText: [NSString stringWithUTF8String: title]]; [alert setInformativeText: [NSString stringWithUTF8String: message]]; - + if( type == DT_ERROR ) [alert setAlertStyle: NSCriticalAlertStyle]; else [alert setAlertStyle: NSWarningAlertStyle]; - + switch( type ) { default: [alert runModal]; - return DR_OK; - + result = DR_OK; + break; + case DT_YES_NO: [alert addButtonWithTitle: @"Yes"]; [alert addButtonWithTitle: @"No"]; switch( [alert runModal] ) { default: - case NSAlertFirstButtonReturn: return DR_YES; - case NSAlertSecondButtonReturn: return DR_NO; + case NSAlertFirstButtonReturn: result = DR_YES; break; + case NSAlertSecondButtonReturn: result = DR_NO; break; } - + break; + case DT_OK_CANCEL: [alert addButtonWithTitle: @"OK"]; [alert addButtonWithTitle: @"Cancel"]; - + switch( [alert runModal] ) { default: - case NSAlertFirstButtonReturn: return DR_OK; - case NSAlertSecondButtonReturn: return DR_CANCEL; + case NSAlertFirstButtonReturn: result = DR_OK; break; + case NSAlertSecondButtonReturn: result = DR_CANCEL; break; } + break; } + + [alert release]; + + return result; } /*