Skip to content

Commit

Permalink
fix pretty bad memory leak when applying capes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzielenski committed Oct 13, 2019
1 parent 35410ba commit 21626bf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Mousecape/Mousecape.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
FAAEF8F7189EB34700145DF8 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FAAEF8F6189EB34700145DF8 /* QuartzCore.framework */; };
FAAEF94E189EFC9300145DF8 /* create.m in Sources */ = {isa = PBXBuildFile; fileRef = FA8FF773189D67B100750E51 /* create.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
FAAEF94F189EFC9600145DF8 /* backup.m in Sources */ = {isa = PBXBuildFile; fileRef = FA8FF76D189D66CB00750E51 /* backup.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
FAAEF950189EFC9800145DF8 /* apply.m in Sources */ = {isa = PBXBuildFile; fileRef = FA8FF770189D66D800750E51 /* apply.m */; };
FAAEF950189EFC9800145DF8 /* apply.m in Sources */ = {isa = PBXBuildFile; fileRef = FA8FF770189D66D800750E51 /* apply.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
FAAEF951189F0CC300145DF8 /* restore.m in Sources */ = {isa = PBXBuildFile; fileRef = FA8FF76A189D664400750E51 /* restore.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
FAAEF957189F4ED300145DF8 /* scale.m in Sources */ = {isa = PBXBuildFile; fileRef = FAAEF956189F4ED300145DF8 /* scale.m */; };
FAAEF958189F4F8200145DF8 /* scale.m in Sources */ = {isa = PBXBuildFile; fileRef = FAAEF956189F4ED300145DF8 /* scale.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
Expand Down
2 changes: 1 addition & 1 deletion Mousecape/Mousecape/Mousecape-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1672</string>
<string>1683</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
8 changes: 4 additions & 4 deletions Mousecape/mousecloak/apply.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ BOOL applyCapeForIdentifier(NSDictionary *cursor, NSString *identifier, BOOL res
CFTypeID type = CFGetTypeID((__bridge CFTypeRef)object);
NSBitmapImageRep *rep;
if (type == CGImageGetTypeID()) {
rep = [[NSBitmapImageRep alloc] initWithCGImage:(__bridge CGImageRef)object];
rep = [[[NSBitmapImageRep alloc] initWithCGImage:(__bridge CGImageRef)object] autorelease];
} else {
rep = [[NSBitmapImageRep alloc] initWithData:object];
rep = [[[NSBitmapImageRep alloc] initWithData:object] autorelease];
}
if (!lefty || restore || !pointer) {
// special case if array has a type of CGImage already there is no need to convert it
Expand All @@ -78,7 +78,7 @@ BOOL applyCapeForIdentifier(NSDictionary *cursor, NSString *identifier, BOOL res
images[images.count] = (__bridge id)[rep.ensuredSRGBSpace CGImage];

} else {
NSBitmapImageRep *newRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
NSBitmapImageRep *newRep = [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:rep.pixelsWide
pixelsHigh:rep.pixelsHigh
bitsPerSample:8
Expand All @@ -87,7 +87,7 @@ BOOL applyCapeForIdentifier(NSDictionary *cursor, NSString *identifier, BOOL res
isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
bytesPerRow:4 * rep.pixelsWide
bitsPerPixel:32];
bitsPerPixel:32] autorelease];
NSGraphicsContext *ctx = [NSGraphicsContext graphicsContextWithBitmapImageRep:newRep];
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:ctx];
Expand Down
4 changes: 2 additions & 2 deletions Mousecape/mousecloak/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int main(int argc, char * argv[]) {
options.applicationVersion = ^{ return @"2.0"; };
options.applicationBuild = ^{ return @""; };
options.printHelpHeader = ^{ return @(BOLD WHITE "%APPNAME v%APPVERSION" RESET); };
options.printHelpFooter = ^{ return @(BOLD WHITE "Copyright © 2013-14 Alex Zielenski" RESET); };
options.printHelpFooter = ^{ return @(BOLD WHITE "Copyright © 2013-20 Alex Zielenski" RESET); };

GBCommandLineParser *parser = [[[GBCommandLineParser alloc] init] autorelease];
[options registerOptionsToCommandLineParser:parser];
Expand All @@ -81,7 +81,7 @@ int main(int argc, char * argv[]) {
MMLog(BOLD RED "Missing value for command line option %s, try --help!" RESET, option.UTF8String);
break;
case GBParseFlagArgument:
[settings addArgument:value];
[settings setObject:@YES forKey:value];
break;
case GBParseFlagOption:
[settings setObject:value forKey:option];
Expand Down

0 comments on commit 21626bf

Please sign in to comment.