* Fix a memory leak in OS X Sys_Dialog

* Fix compilation on Snow Leopard
This commit is contained in:
Tim Angus 2010-02-26 16:32:49 +00:00
parent ed313e3606
commit 3ebe048968
3 changed files with 36 additions and 25 deletions

View file

@ -1113,7 +1113,7 @@ makedirs:
# QVM BUILD TOOLS # QVM BUILD TOOLS
############################################################################# #############################################################################
TOOLS_OPTIMIZE = -g -O2 -Wall -fno-strict-aliasing TOOLS_OPTIMIZE = -g -Wall -fno-strict-aliasing
TOOLS_CFLAGS += $(TOOLS_OPTIMIZE) \ TOOLS_CFLAGS += $(TOOLS_OPTIMIZE) \
-DTEMPDIR=\"$(TEMPDIR)\" -DSYSTEM=\"\" \ -DTEMPDIR=\"$(TEMPDIR)\" -DSYSTEM=\"\" \
-I$(Q3LCCSRCDIR) \ -I$(Q3LCCSRCDIR) \

View file

@ -119,6 +119,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#elif defined __i386__ #elif defined __i386__
#define ARCH_STRING "i386" #define ARCH_STRING "i386"
#define Q3_LITTLE_ENDIAN #define Q3_LITTLE_ENDIAN
#elif defined __x86_64__
#define ARCH_STRING "x86_64"
#define Q3_LITTLE_ENDIAN
#endif #endif
#define DLL_EXT ".dylib" #define DLL_EXT ".dylib"

View file

@ -41,19 +41,19 @@ Sys_TempPath
*/ */
const char *Sys_TempPath( void ) const char *Sys_TempPath( void )
{ {
static UInt8 posixPath[ MAX_OSPATH ]; static UInt8 posixPath[ MAX_OSPATH ];
FSRef ref; FSRef ref;
if( FSFindFolder( kOnAppropriateDisk, if( FSFindFolder( kOnAppropriateDisk,
kTemporaryFolderType, kCreateFolder, &ref ) == noErr ) kTemporaryFolderType, kCreateFolder, &ref ) == noErr )
{ {
if( FSRefMakePath( &ref, posixPath, if( FSRefMakePath( &ref, posixPath,
sizeof( posixPath ) - 1 ) == noErr ) sizeof( posixPath ) - 1 ) == noErr )
{ {
return (const char *)posixPath; return (const char *)posixPath;
} }
} }
return "/tmp"; return "/tmp";
} }
/* /*
@ -65,7 +65,8 @@ Display an OS X dialog box
*/ */
dialogResult_t Sys_Dialog( dialogType_t type, const char *message, const char *title ) 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 setMessageText: [NSString stringWithUTF8String: title]];
[alert setInformativeText: [NSString stringWithUTF8String: message]]; [alert setInformativeText: [NSString stringWithUTF8String: message]];
@ -79,7 +80,8 @@ dialogResult_t Sys_Dialog( dialogType_t type, const char *message, const char *t
{ {
default: default:
[alert runModal]; [alert runModal];
return DR_OK; result = DR_OK;
break;
case DT_YES_NO: case DT_YES_NO:
[alert addButtonWithTitle: @"Yes"]; [alert addButtonWithTitle: @"Yes"];
@ -87,9 +89,10 @@ dialogResult_t Sys_Dialog( dialogType_t type, const char *message, const char *t
switch( [alert runModal] ) switch( [alert runModal] )
{ {
default: default:
case NSAlertFirstButtonReturn: return DR_YES; case NSAlertFirstButtonReturn: result = DR_YES; break;
case NSAlertSecondButtonReturn: return DR_NO; case NSAlertSecondButtonReturn: result = DR_NO; break;
} }
break;
case DT_OK_CANCEL: case DT_OK_CANCEL:
[alert addButtonWithTitle: @"OK"]; [alert addButtonWithTitle: @"OK"];
@ -98,10 +101,15 @@ dialogResult_t Sys_Dialog( dialogType_t type, const char *message, const char *t
switch( [alert runModal] ) switch( [alert runModal] )
{ {
default: default:
case NSAlertFirstButtonReturn: return DR_OK; case NSAlertFirstButtonReturn: result = DR_OK; break;
case NSAlertSecondButtonReturn: return DR_CANCEL; case NSAlertSecondButtonReturn: result = DR_CANCEL; break;
} }
break;
} }
[alert release];
return result;
} }
/* /*