Skip to content

Commit

Permalink
md: fix provided by Mike Alexander which adds an NSAutoreleasePool to…
Browse files Browse the repository at this point in the history
… the main program so that the Cocoa code called by Mulberry won't leak autorelease objects and flood the console with related error messages.

git-svn-id: https://svn.mulberrymail.com/mulberry/Mulberry/branches/users/shared/v4.1d1@389 a91246af-f21b-0410-bd1c-c3c7fc455132
  • Loading branch information
svnusers committed Jun 16, 2011
1 parent dbcd36c commit 8aadd57
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
21 changes: 14 additions & 7 deletions MacOS/Sources/Application/General/CMulberryApp.cp
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ struct sigaction {
// ¥ Main Program
// ===========================================================================

static void runapp(void);

int main()
{

InitializeCocoa();

#ifdef DATA_VIEWER
DataViewLibInit(); // View opaque types in source debugger
#endif
Expand Down Expand Up @@ -200,6 +200,17 @@ int main()
UQDGlobals::InitializeToolbox();
CSoundManager::sSoundManager.Initialize(); // Must do after toolbox init as this may have to init Quicktime

InitializeCocoa(runapp);

#ifdef LEAKS
DebugNewReportLeaks();
#endif

return 0;
}

static void runapp()
{
try
{
CMulberryApp theApp; // Create instance of your Application
Expand All @@ -211,11 +222,7 @@ int main()
catch(...)
{
}
#ifdef LEAKS
DebugNewReportLeaks();
#endif

return 0;
return;
}


Expand Down
2 changes: 1 addition & 1 deletion MacOS/Sources/Application/General/CMulberryCocoaApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
extern "C" {
#endif

void InitializeCocoa(void);
void InitializeCocoa(void (*runapp)(void));

#ifdef __cplusplus
}
Expand Down
7 changes: 6 additions & 1 deletion MacOS/Sources/Application/General/CMulberryCocoaApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@

#import "CMulberryCocoaApp.h"

void InitializeCocoa(void)
void InitializeCocoa(void (*runapp)(void))
{
NSApplicationLoad();
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

runapp();

[pool drain];
}

0 comments on commit 8aadd57

Please sign in to comment.