Skip to content
This repository has been archived by the owner on Oct 24, 2019. It is now read-only.

Commit

Permalink
Static analyzer improvements: memory leak plugging, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Morgan committed Oct 14, 2009
1 parent 8afc575 commit d5035ea
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 44 deletions.
29 changes: 6 additions & 23 deletions Resources/English.lproj/MainMenu.xib
Expand Up @@ -2,9 +2,9 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1060</int>
<string key="IBDocument.SystemVersion">10A432</string>
<string key="IBDocument.SystemVersion">10B504</string>
<string key="IBDocument.InterfaceBuilderVersion">732</string>
<string key="IBDocument.AppKitVersion">1038</string>
<string key="IBDocument.AppKitVersion">1038.2</string>
<string key="IBDocument.HIToolboxVersion">437.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
Expand Down Expand Up @@ -3477,14 +3477,6 @@
</object>
<int key="connectionID">868</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">uploadWindow</string>
<reference key="source" ref="108242027"/>
<reference key="destination" ref="483958638"/>
</object>
<int key="connectionID">870</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">hidden: isBusy</string>
Expand Down Expand Up @@ -4418,14 +4410,6 @@
</object>
<int key="connectionID">1681</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">documentController</string>
<reference key="source" ref="388294736"/>
<reference key="destination" ref="603642860"/>
</object>
<int key="connectionID">1682</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">filesController</string>
Expand Down Expand Up @@ -8778,10 +8762,10 @@
<string key="NS.key.0">displayError:</string>
<string key="NS.object.0">SUDocument</string>
</object>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="documentController">SUDocumentArrayController</string>
<string key="window">NSWindow</string>
</dictionary>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">window</string>
<string key="NS.object.0">NSWindow</string>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Source/MVC/Controller/SUUploadErrorController.h</string>
Expand All @@ -8801,7 +8785,6 @@
<dictionary class="NSMutableDictionary" key="outlets">
<string key="db">SUDatabaseHelper</string>
<string key="loginSheet">NSWindow</string>
<string key="uploadWindow">NSWindow</string>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
Expand Down
4 changes: 2 additions & 2 deletions Scribd Uploader.xcodeproj/project.pbxproj
Expand Up @@ -1165,7 +1165,7 @@
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
8D1107260486CEB800E47090 /* Scribd Uploader */ = {
8D1107260486CEB800E47090 /* Mac */ = {
isa = PBXNativeTarget;
buildConfigurationList = 26FC0A840875C7B200E6366F /* Build configuration list for PBXNativeTarget "Scribd Uploader" */;
buildPhases = (
Expand Down Expand Up @@ -1209,7 +1209,7 @@
);
projectRoot = "";
targets = (
8D1107260486CEB800E47090 /* Scribd Uploader */,
8D1107260486CEB800E47090 /* Mac */,
);
};
/* End PBXProject section */
Expand Down
1 change: 1 addition & 0 deletions Source/MVC/Controller/Delegates/SUAppDelegate.m
Expand Up @@ -97,6 +97,7 @@ + (void) initialize {
NSLocalizedString(@"Click this button to learn more about why your document could not have its metadata assigned.", NULL), @"Caution",
NULL];
[NSValueTransformer setValueTransformer:[[[SUMappingValueTransformer alloc] initWithDictionary:statusButtonToolTips] autorelease] forName:@"SUStatusButtonToolTip"];
[statusButtonToolTips release];

SUHumanizeDimensionValueTransformer *timeValueTransformer = [[SUHumanizeDimensionValueTransformer alloc] initWithRootUnit:NSLocalizedString(@"second", @"unit of time")];
[timeValueTransformer addUnitWithName:NSLocalizedString(@"minute", @"unit of time") sizeInRootUnits:60];
Expand Down
4 changes: 2 additions & 2 deletions Source/MVC/Controller/Delegates/SULoginSheetDelegate.m
Expand Up @@ -103,10 +103,10 @@ - (IBAction) cancel:(id)sender {

- (IBAction) showHelp:(id)sender {
NSString *selectedTab = [[tabs selectedTabViewItem] identifier];
NSString *anchor;
NSString *anchor = NULL;
if ([selectedTab isEqualToString:@"login"]) anchor = @"existing_account";
else if ([selectedTab isEqualToString:@"signup"]) anchor = @"new_account";
[[NSHelpManager sharedHelpManager] openHelpAnchor:anchor inBook:@"Scribd Uploader Help"];
if (anchor) [[NSHelpManager sharedHelpManager] openHelpAnchor:anchor inBook:@"Scribd Uploader Help"];
}

@end
1 change: 1 addition & 0 deletions Source/MVC/Controller/Helpers/SUConversionStatusTracker.m
Expand Up @@ -55,6 +55,7 @@ - (void) requestFinished:(ASIHTTPRequest *)request {
NSXMLDocument *xml = [[NSXMLDocument alloc] initWithXMLString:[request responseString] options:0 error:&error];
if (xml) {
NSDictionary *response = [[SUScribdAPI sharedAPI] parseResponseXML:xml error:&error];
[xml release];
if (response) {
NSString *status = [response objectForKey:@"conversion_status"];
if (!status) return;
Expand Down
2 changes: 1 addition & 1 deletion Source/MVC/Controller/Helpers/SUUploadHelper.h
Expand Up @@ -21,7 +21,7 @@
NSString *newUserLogin, *newUserEmail, *newUserPassword, *newUserName;
NSError *newUserLoginError, *newUserEmailError, *newUserPasswordError, *newUserNameError;
NSMutableSet *uploadDelegates;
IBOutlet NSWindow *uploadWindow, *loginSheet;
IBOutlet NSWindow *loginSheet;
IBOutlet SUDatabaseHelper *db;
}

Expand Down
8 changes: 4 additions & 4 deletions Source/MVC/Controller/Helpers/SUUploadHelper.m
Expand Up @@ -239,7 +239,7 @@ + (NSSet *) keyPathsForValuesAffectingUploadComplete {

- (BOOL) validateNewUserLogin:(id *)login error:(NSError **)error {
if (newUserLoginError) {
if (!error) *error = [newUserLoginError autorelease];
if (error) *error = [newUserLoginError autorelease];
return NO;
}
else return YES;
Expand All @@ -252,7 +252,7 @@ - (BOOL) validateNewUserLogin:(id *)login error:(NSError **)error {

- (BOOL) validateNewUserPassword:(id *)password error:(NSError **)error {
if (newUserPasswordError) {
if (!error) *error = [newUserPasswordError autorelease];
if (error) *error = [newUserPasswordError autorelease];
return NO;
}
else return YES;
Expand All @@ -265,7 +265,7 @@ - (BOOL) validateNewUserPassword:(id *)password error:(NSError **)error {

- (BOOL) validateNewUserEmail:(id *)email error:(NSError **)error {
if (newUserEmailError) {
if (!error) *error = [newUserEmailError autorelease];
if (error) *error = [newUserEmailError autorelease];
return NO;
}
else return YES;
Expand All @@ -278,7 +278,7 @@ - (BOOL) validateNewUserEmail:(id *)email error:(NSError **)error {

- (BOOL) validateNewUserName:(id *)name error:(NSError **)error {
if (newUserNameError) {
if (!error) *error = [newUserNameError autorelease];
if (error) *error = [newUserNameError autorelease];
return NO;
}
else return YES;
Expand Down
4 changes: 2 additions & 2 deletions Source/MVC/Controller/SUPreferencesWindowController.m
Expand Up @@ -47,11 +47,11 @@ - (IBAction) checkForUpdates:(id)sender {
}

- (IBAction) showHelp:(id)sender {
NSString *anchor;
NSString *anchor = NULL;
if ([[self activeView] isEqualTo:automaticUpdatesView]) anchor = @"automatic_updates";
if ([[self activeView] isEqualTo:uploadingView]) anchor = @"uploading_preferences";
if ([[self activeView] isEqualTo:metadataView]) anchor = @"metadata_preferences";
[[NSHelpManager sharedHelpManager] openHelpAnchor:anchor inBook:@"Scribd Uploader Help"];
if (anchor) [[NSHelpManager sharedHelpManager] openHelpAnchor:anchor inBook:@"Scribd Uploader Help"];
}

@end
Expand Down
1 change: 0 additions & 1 deletion Source/MVC/Controller/SUUploadErrorController.h
Expand Up @@ -9,7 +9,6 @@
@interface SUUploadErrorController : NSObject {
@private
IBOutlet NSWindow *window;
IBOutlet SUDocumentArrayController *documentController;
}

#pragma mark Displaying an error
Expand Down
Expand Up @@ -89,18 +89,13 @@ - (id) transformedValue:(id)value {
if ([value isKindOfClass:[NSNumber class]]) {
double scalar = [(NSNumber *)value doubleValue];

SUHumanizeUnit *prev = NULL;
SUHumanizeUnit *unit = firstUnit;
double scalarInUnits;

while (YES) {
scalarInUnits = scalar/unit->value;
if (scalarInUnits >= 1.0) break; // first unit whose value is at least 1
if (unit->next) {
// advance to the next-smallest unit
prev = unit;
unit = unit->next;
}
if (unit->next) unit = unit->next; // advance to the next-smallest unit
else break; // end of the line; use the smallest unit we've got
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Support/Categories/NSArray_SUAdditions.m
Expand Up @@ -25,7 +25,7 @@ - (NSArray *) reversedArray {
- (NSArray *) map:(id (^)(id value))block {
NSMutableArray *mappedArray = [[NSMutableArray alloc] initWithCapacity:[self count]];
for (id object in self) [mappedArray addObject:block(object)];
return mappedArray;
return [mappedArray autorelease];
}

@end
7 changes: 5 additions & 2 deletions Source/Support/Network/SUScribdAPI.m
Expand Up @@ -131,7 +131,10 @@ - (NSDictionary *) callAPIMethod:(NSString *)method parameters:(NSDictionary *)p
NSURL *URL = [self APIURLWithMethod:method parameters:parameters];
NSXMLDocument *xml = [[NSXMLDocument alloc] initWithContentsOfURL:URL options:NSXMLDocumentTidyXML error:error];

if (*error) return NULL; // xml will be nil so no need to release
if (error && *error) {
if (xml) [xml release];
return NULL;
}

NSDictionary *results = [self parseResponseXML:xml error:error];
[xml release];
Expand Down Expand Up @@ -276,7 +279,7 @@ - (NSDictionary *) parseResponseXML:(NSXMLDocument *)xml error:(NSError **)error
errorCode = -1;
errorInfo = [[NSDictionary alloc] initWithObject:NSLocalizedString(@"Improper format", @"XML response") forKey:NSLocalizedFailureReasonErrorKey];
}
*error = [NSError errorWithDomain:SUScribdAPIErrorDomain code:errorCode userInfo:errorInfo];
if (error) *error = [NSError errorWithDomain:SUScribdAPIErrorDomain code:errorCode userInfo:errorInfo];
[errorInfo release];
return NULL;
}
Expand Down

0 comments on commit d5035ea

Please sign in to comment.