http://www.mediawiki.org/wiki/Special:Code/MediaWiki/84816
Revision: 84816 Author: hartman Date: 2011-03-26 19:29:13 +0000 (Sat, 26 Mar 2011) Log Message: ----------- Fix some obj-c memleaks and warnings. Modified Paths: -------------- trunk/tools/WikiSnaps/Classes/CommonsUpload.m trunk/tools/WikiSnaps/Classes/ImageUploadViewController.m trunk/tools/WikiSnaps/Classes/XMLtoDict/XMLReader.h trunk/tools/WikiSnaps/Classes/XMLtoDict/XMLReader.m Modified: trunk/tools/WikiSnaps/Classes/CommonsUpload.m =================================================================== --- trunk/tools/WikiSnaps/Classes/CommonsUpload.m 2011-03-26 19:29:03 UTC (rev 84815) +++ trunk/tools/WikiSnaps/Classes/CommonsUpload.m 2011-03-26 19:29:13 UTC (rev 84816) @@ -16,7 +16,7 @@ /* Private */ @interface CommonsUpload (Internal) -- (void)checkXML: (NSDictionary *)dict forAPIError: (NSError **)error; +- (BOOL)checkXML: (NSDictionary *)dict forAPIError: (NSError **)error; @end @@ -33,7 +33,9 @@ NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"yyyy-MM-dd"]; NSString *dateString = [formatter stringFromDate:today]; - NSLog(dateString); + [formatter release]; + + NSLog(@"%@", dateString); return [NSString stringWithFormat: @"{{Information\n|Description={{en|1=%@}}\n|Author=[[User:%@]]\n|Source={{own}}\n|Date=%@\n|Permission=\n|other_versions=\n}}\n\n== {{int:license}} ==\n%@\n\n[[Category:%@]]", description, @@ -298,17 +300,23 @@ return NO; } -- (void)checkXML: (NSDictionary *)dict forAPIError: (NSError **)error { +/** + * @return true if the XML was good, false if an error occured + */ +- (BOOL)checkXML: (NSDictionary *)dict forAPIError: (NSError **)error { NSDictionary *errorDict = [[dict objectForKey:@"api"] objectForKey: @"error"]; if( errorDict ) { NSMutableDictionary *nsErrorDict = [NSMutableDictionary dictionaryWithCapacity:5]; [nsErrorDict setObject: @"Communication failure with server" forKey: NSLocalizedDescriptionKey ]; [nsErrorDict setObject: [errorDict objectForKey:@"info"] forKey: NSLocalizedFailureReasonErrorKey ]; -NSLog( [errorDict objectForKey:@"info"] ); +NSLog( @"%@", [errorDict objectForKey:@"info"] ); - NSError *APIError = [NSError errorWithDomain: @"COMMONS_API_DOMAIN" code: 1 userInfo: nsErrorDict]; - *error = APIError; + if (error != NULL) { + *error = [NSError errorWithDomain: @"COMMONS_API_DOMAIN" code: 1 userInfo: nsErrorDict]; + } + return FALSE; } + return TRUE; } @end Modified: trunk/tools/WikiSnaps/Classes/ImageUploadViewController.m =================================================================== --- trunk/tools/WikiSnaps/Classes/ImageUploadViewController.m 2011-03-26 19:29:03 UTC (rev 84815) +++ trunk/tools/WikiSnaps/Classes/ImageUploadViewController.m 2011-03-26 19:29:13 UTC (rev 84816) @@ -99,7 +99,7 @@ } - (void)uploadFailed:(NSString *)error { - NSLog(error); + NSLog(@"%@", error); [self.navigationController popToRootViewControllerAnimated:YES]; } Modified: trunk/tools/WikiSnaps/Classes/XMLtoDict/XMLReader.h =================================================================== --- trunk/tools/WikiSnaps/Classes/XMLtoDict/XMLReader.h 2011-03-26 19:29:03 UTC (rev 84815) +++ trunk/tools/WikiSnaps/Classes/XMLtoDict/XMLReader.h 2011-03-26 19:29:13 UTC (rev 84816) @@ -6,7 +6,7 @@ #import <Foundation/Foundation.h> -@interface XMLReader : NSObject +@interface XMLReader : NSObject <NSXMLParserDelegate> { NSMutableArray *dictionaryStack; NSMutableString *textInProgress; Modified: trunk/tools/WikiSnaps/Classes/XMLtoDict/XMLReader.m =================================================================== --- trunk/tools/WikiSnaps/Classes/XMLtoDict/XMLReader.m 2011-03-26 19:29:03 UTC (rev 84815) +++ trunk/tools/WikiSnaps/Classes/XMLtoDict/XMLReader.m 2011-03-26 19:29:13 UTC (rev 84816) @@ -68,6 +68,7 @@ NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data]; parser.delegate = self; BOOL success = [parser parse]; + [parser release]; // Return the stack's root dictionary on success if (success) _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs