Browse files

Merge pull request #5 from cjhanson/master

Fixed memory leaks and analyzer warnings.
  • Loading branch information...
2 parents 3b4f52f + b14aebf commit 7b165a51f9c1dbad0e13982f069cadc8ce7d7097 @TwoLivesLeft committed Apr 26, 2012
View
2 CodeaTemplate/CodeaTemplate/CodifyAppDelegate.m
@@ -83,7 +83,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
}
- self.currentProject = [[Project alloc] initWithPath:destPath validFileTypes:[NSArray arrayWithObjects:@"lua", @"plist", nil]];
+ self.currentProject = [[[Project alloc] initWithPath:destPath validFileTypes:[NSArray arrayWithObjects:@"lua", @"plist", nil]] autorelease];
[self showRenderView:YES animated:NO];
[[CodifyScriptExecute sharedInstance] runProject:self.currentProject];
View
20 CodeaTemplate/Codify/BasicRendererViewController.mm
@@ -102,6 +102,18 @@ - (int) orientationFromUIOrientation:(UIInterfaceOrientation)uio
#pragma mark - Internal Initialization
+- (id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
+{
+ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
+
+ if(self){
+ supportedOrientations = [[NSMutableSet alloc] initWithCapacity:4];
+ [self addSupportedOrientation:ORIENTATION_ANY];
+ }
+
+ return self;
+}
+
- (void) setup
{
self.showButtons = NO;
@@ -116,8 +128,6 @@ - (void) setup
renderManager = [[RenderManager alloc] init];
physicsManager = [[PhysicsManager alloc] init];
- supportedOrientations = [[NSMutableSet set] retain];
- [self addSupportedOrientation:ORIENTATION_ANY];
if (!aContext)
NSLog(@"Failed to create ES context");
@@ -478,9 +488,7 @@ - (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterface
#pragma mark - View preparation
- (void) prepareViewForDisplay
-{
- [self addSupportedOrientation:ORIENTATION_ANY];
-
+{
//Do some basic GL setup
[self startAnimation];
[self initialDrawSetup];
@@ -1138,7 +1146,7 @@ - (void) addSupportedOrientation:(NSUInteger)codeaOrientation
[supportedOrientations addObject:[NSNumber numberWithUnsignedInteger:UIInterfaceOrientationLandscapeRight]];
[supportedOrientations addObject:[NSNumber numberWithUnsignedInteger:UIInterfaceOrientationPortrait]];
[supportedOrientations addObject:[NSNumber numberWithUnsignedInteger:UIInterfaceOrientationPortraitUpsideDown]];
- break;
+ break;
default: //Default to landscape left and right
[supportedOrientations addObject:[NSNumber numberWithUnsignedInteger:UIInterfaceOrientationLandscapeLeft]];
View
8 CodeaTemplate/Codify/CodifyScriptExecute.m
@@ -36,7 +36,7 @@ - (id) init
self = [super init];
if( self )
{
- preloadScripts = [[NSMutableArray array] retain];
+ preloadScripts = [[NSMutableArray alloc] initWithCapacity:31];
/*
//Lua Socket
@@ -51,8 +51,8 @@ - (id) init
*/
//Pre-load classes and sandbox lua files
- [preloadScripts addObject:[SCRIPT_STRING("LuaSandbox") retain]];
- [preloadScripts addObject:[SCRIPT_STRING("Class") retain]];
+ [preloadScripts addObject:SCRIPT_STRING("LuaSandbox")];
+ [preloadScripts addObject:SCRIPT_STRING("Class")];
//luaSandbox = [[NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"LuaSandbox" ofType:@"lua"] usedEncoding:NULL error:NULL] retain];
//luaClasses = [[NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Class" ofType:@"lua"] usedEncoding:NULL error:NULL] retain];
@@ -105,7 +105,7 @@ - (BOOL) validateProject:(Project*)project
//Check here because the open source EditorBuffer doesnt have this message
if ([buffer respondsToSelector:@selector(clearErrorMessage)])
{
- [buffer clearErrorMessages];
+ [buffer performSelector:@selector(clearErrorMessage)];
}
//Attempt to load this buffer into the Lua state
View
1 CodeaTemplate/Codify/Persistence.m
@@ -428,6 +428,7 @@ int readData(lua_State *L, NSDictionary* readFromDict)
CGDataProviderRelease(provider);
CGImageRelease(imageRef);
+ CGColorSpaceRelease(colorSpaceRef);
return newImage;
}

0 comments on commit 7b165a5

Please sign in to comment.