Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed memory leaks and analyzer warnings. #5

Merged
merged 2 commits into from

2 participants

@cjhanson

CodifyAppDelegate

  • Fixed memory leak by autoreleasing "Project" where the retained property "self.currentProject" was being assigned a retained "Project" in "- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions"

BasicRendererViewController

  • Fixed runtime warning about returning NO to all supported orientations by setting up the supported orientations in the init method instead of the setup method
  • Removed superfluous call to add SupportedOrientations from prepareViewForDisplay

CodifyScriptExecute

  • init preloadScripts to an array with a capacity rather than using an autoreleased object
  • Fixed memory leak by removing "retain" from adding objects to the preloadScripts array (the array will retain objects added and release when removed internally)
  • Fixed warning about unknown selector "clearErrorMessage" by using performSelector: instead of just calling the selector directly

Persistence

  • Fixed memory leak in createUIImageFromImage() by releasing the colorSpaceRef
cjhanson added some commits
@cjhanson cjhanson Fixed memory leaks and analyzer warnings.
CodifyAppDelegate
 - Fixed memory leak by autoreleasing "Project" where the retained property "self.currentProject" was being assigned a retained "Project" in "- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions"

BasicRendererViewController
 - Fixed runtime warning about returning NO to all supported orientations by setting up the supported orientations in the init method instead of the setup method
 - Removed superfluous call to add SupportedOrientations from prepareViewForDisplay

CodifyScriptExecute
 - init preloadScripts to an array with a capacity rather than using an autoreleased object
 - Fixed memory leak by removing "retain" from adding objects to the preloadScripts array (the array will retain objects added and release when removed internally)
 - Fixed warning about unknown selector "clearErrorMessage" by using performSelector: instead of just calling the selector directly

Persistence
 - Fixed memory leak in createUIImageFromImage() by releasing the colorSpaceRef
a16cff2
@cjhanson cjhanson Merge branch 'master' of https://github.com/TwoLivesLeft/Codea-Runtime b14aebf
@TwoLivesLeft TwoLivesLeft merged commit 7b165a5 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 25, 2012
  1. @cjhanson

    Fixed memory leaks and analyzer warnings.

    cjhanson authored
    CodifyAppDelegate
     - Fixed memory leak by autoreleasing "Project" where the retained property "self.currentProject" was being assigned a retained "Project" in "- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions"
    
    BasicRendererViewController
     - Fixed runtime warning about returning NO to all supported orientations by setting up the supported orientations in the init method instead of the setup method
     - Removed superfluous call to add SupportedOrientations from prepareViewForDisplay
    
    CodifyScriptExecute
     - init preloadScripts to an array with a capacity rather than using an autoreleased object
     - Fixed memory leak by removing "retain" from adding objects to the preloadScripts array (the array will retain objects added and release when removed internally)
     - Fixed warning about unknown selector "clearErrorMessage" by using performSelector: instead of just calling the selector directly
    
    Persistence
     - Fixed memory leak in createUIImageFromImage() by releasing the colorSpaceRef
  2. @cjhanson
This page is out of date. Refresh to see the latest.
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;
}
Something went wrong with that request. Please try again.