r84816 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84815‎ | r84816 | r84817 >
Date:19:29, 26 March 2011
Author:hartman
Status:deferred
Tags:
Comment:
Fix some obj-c memleaks and warnings.
Modified paths:
  • /trunk/tools/WikiSnaps/Classes/CommonsUpload.m (modified) (history)
  • /trunk/tools/WikiSnaps/Classes/ImageUploadViewController.m (modified) (history)
  • /trunk/tools/WikiSnaps/Classes/XMLtoDict/XMLReader.h (modified) (history)
  • /trunk/tools/WikiSnaps/Classes/XMLtoDict/XMLReader.m (modified) (history)

Diff [purge]

Index: trunk/tools/WikiSnaps/Classes/ImageUploadViewController.m
@@ -99,7 +99,7 @@
100100 }
101101
102102 - (void)uploadFailed:(NSString *)error {
103 - NSLog(error);
 103+ NSLog(@"%@", error);
104104 [self.navigationController popToRootViewControllerAnimated:YES];
105105 }
106106
Index: trunk/tools/WikiSnaps/Classes/XMLtoDict/XMLReader.h
@@ -6,7 +6,7 @@
77 #import <Foundation/Foundation.h>
88
99
10 -@interface XMLReader : NSObject
 10+@interface XMLReader : NSObject <NSXMLParserDelegate>
1111 {
1212 NSMutableArray *dictionaryStack;
1313 NSMutableString *textInProgress;
Index: trunk/tools/WikiSnaps/Classes/XMLtoDict/XMLReader.m
@@ -68,6 +68,7 @@
6969 NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
7070 parser.delegate = self;
7171 BOOL success = [parser parse];
 72+ [parser release];
7273
7374 // Return the stack's root dictionary on success
7475 if (success)
Index: trunk/tools/WikiSnaps/Classes/CommonsUpload.m
@@ -16,7 +16,7 @@
1717 /* Private */
1818 @interface CommonsUpload (Internal)
1919
20 -- (void)checkXML: (NSDictionary *)dict forAPIError: (NSError **)error;
 20+- (BOOL)checkXML: (NSDictionary *)dict forAPIError: (NSError **)error;
2121 @end
2222
2323
@@ -33,7 +33,9 @@
3434 NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
3535 [formatter setDateFormat:@"yyyy-MM-dd"];
3636 NSString *dateString = [formatter stringFromDate:today];
37 - NSLog(dateString);
 37+ [formatter release];
 38+
 39+ NSLog(@"%@", dateString);
3840
3941 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:%@]]",
4042 description,
@@ -298,17 +300,23 @@
299301 return NO;
300302 }
301303
302 -- (void)checkXML: (NSDictionary *)dict forAPIError: (NSError **)error {
 304+/**
 305+ * @return true if the XML was good, false if an error occured
 306+ */
 307+- (BOOL)checkXML: (NSDictionary *)dict forAPIError: (NSError **)error {
303308 NSDictionary *errorDict = [[dict objectForKey:@"api"] objectForKey: @"error"];
304309 if( errorDict ) {
305310 NSMutableDictionary *nsErrorDict = [NSMutableDictionary dictionaryWithCapacity:5];
306311 [nsErrorDict setObject: @"Communication failure with server" forKey: NSLocalizedDescriptionKey ];
307312 [nsErrorDict setObject: [errorDict objectForKey:@"info"] forKey: NSLocalizedFailureReasonErrorKey ];
308 -NSLog( [errorDict objectForKey:@"info"] );
 313+NSLog( @"%@", [errorDict objectForKey:@"info"] );
309314
310 - NSError *APIError = [NSError errorWithDomain: @"COMMONS_API_DOMAIN" code: 1 userInfo: nsErrorDict];
311 - *error = APIError;
 315+ if (error != NULL) {
 316+ *error = [NSError errorWithDomain: @"COMMONS_API_DOMAIN" code: 1 userInfo: nsErrorDict];
 317+ }
 318+ return FALSE;
312319 }
 320+ return TRUE;
313321 }
314322
315323 @end

Status & tagging log