From: Benjamin R. <be...@us...> - 2004-04-09 03:43:23
|
Update of /cvsroot/ljkit/LJKit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16383 Modified Files: LJJournal.m LJJournal_Private.h LJAccount.m Log Message: Two changes to LJAccount. First, when a new account is created with initWithUsername:, the defaultJournal is set up (previously it would be nil until the first login). Second, during login the journal objects are reused. Previously the entire journal array would be recreated. (P.S. It seems that the a copy of the journal array was leaking during login; that has been fixed.) Index: LJJournal_Private.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJJournal_Private.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LJJournal_Private.h 10 Jan 2004 08:28:28 -0000 1.1 --- LJJournal_Private.h 9 Apr 2004 03:30:09 -0000 1.2 *************** *** 27,30 **** --- 27,31 ---- @interface LJJournal (FrameworkPrivate) + + (LJJournal *)_journalWithName:(NSString *)name account:(LJAccount *)account; + (NSArray *)_journalArrayFromLoginReply:(NSDictionary *)reply account:(LJAccount *)account; - (id)initWithName:(NSString *)name account:(LJAccount *)account; Index: LJJournal.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJJournal.m,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LJJournal.m 16 Mar 2004 02:53:39 -0000 1.3 --- LJJournal.m 9 Apr 2004 03:30:09 -0000 1.4 *************** *** 62,65 **** --- 62,66 ---- NSMutableArray *array; NSString *name; + LJJournal *journal; int count, i; *************** *** 67,76 **** array = [NSMutableArray arrayWithCapacity:(count + 1)]; // add user's own journal (not part of login reply) ! [array addObject:[self _journalWithName:[account username] ! account:account]]; // add others, if present for (i = 1; i <= count; i++) { name = [reply objectForKey:[NSString stringWithFormat:@"access_%d", i]]; ! [array addObject:[self _journalWithName:name account:account]]; } return array; --- 68,80 ---- array = [NSMutableArray arrayWithCapacity:(count + 1)]; // add user's own journal (not part of login reply) ! [array addObject:[account defaultJournal]]; // add others, if present for (i = 1; i <= count; i++) { name = [reply objectForKey:[NSString stringWithFormat:@"access_%d", i]]; ! journal = [account journalNamed:name]; ! if (journal == nil) { ! journal = [self _journalWithName:name account:account]; ! } ! [array addObject:journal]; } return array; Index: LJAccount.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount.m,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LJAccount.m 16 Mar 2004 02:56:49 -0000 1.5 --- LJAccount.m 9 Apr 2004 03:30:09 -0000 1.6 *************** *** 201,204 **** --- 201,205 ---- { NSURL *defaultURL; + LJJournal *journal; if ([self init]) { *************** *** 208,211 **** --- 209,214 ---- defaultURL = [NSURL URLWithString:@"http://www.livejournal.com"]; _server = [[LJServer alloc] initWithURL:defaultURL account:self]; + journal = [LJJournal _journalWithName:_username account:self]; + _journalArray = [[NSArray alloc] initWithObjects:&journal count:1]; } return self; *************** *** 461,464 **** --- 464,468 ---- NSMutableDictionary *parameters; NSNotificationCenter *noticeCenter = [NSNotificationCenter defaultCenter]; + NSArray *journals; NSAssert(password != nil, @"Password must not be nil."); *************** *** 506,511 **** [_server setUseFastServers:YES]; } ! _journalArray = [LJJournal _journalArrayFromLoginReply:reply account:self]; ! [_journalArray retain]; if (loginFlags & LJGetMoodsLoginFlag) { [_moods updateMoodsWithLoginReply:reply]; --- 510,516 ---- [_server setUseFastServers:YES]; } ! journals = [LJJournal _journalArrayFromLoginReply:reply account:self]; ! [_journalArray release]; ! _journalArray = [journals retain]; if (loginFlags & LJGetMoodsLoginFlag) { [_moods updateMoodsWithLoginReply:reply]; |