Changeset 23109
- Timestamp:
- 04/12/2008 01:18:59 PM (7 months ago)
- Files:
-
- trunk/Source/AIContactController.h (modified) (2 diffs)
- trunk/Source/AIContactController.m (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Source/AIContactController.h
r22859 r23109 28 28 #define PREF_GROUP_CONTACT_LIST_DISPLAY @"Contact List Display" 29 29 30 #ifdef DEBUG_BUILD 31 #define CONTACT_OBSERVER_MEMORY_MANAGEMENT_DEBUG TRUE 32 #endif 33 30 34 @class AISortController, AdiumAuthorization, AIContactHidingController; 31 35 … … 48 52 49 53 //Status and Attribute updates 50 NSMutableSet *contactObservers; 54 #ifdef CONTACT_OBSERVER_MEMORY_MANAGEMENT_DEBUG 55 NSMutableArray *contactObservers; 56 #else 57 NSMutableSet *contactObservers; 58 #endif 51 59 NSTimer *delayedUpdateTimer; 52 60 int delayedStatusChanges; trunk/Source/AIContactController.m
r23023 r23109 73 73 #define UID_KEY @"UID" 74 74 75 #ifdef CONTACT_OBSERVER_MEMORY_MANAGEMENT_DEBUG 76 static BOOL unregisterListObjectObserverCalled = NO; 77 #endif 78 75 79 @interface AIContactController (PRIVATE) 76 80 - (AIListGroup *)processGetGroupNamed:(NSString *)serverGroup; … … 122 126 if ((self = [super init])) { 123 127 // 128 #ifdef CONTACT_OBSERVER_MEMORY_MANAGEMENT_DEBUG 129 contactObservers = [[NSMutableArray alloc] init]; 130 #else 124 131 contactObservers = [[NSMutableSet alloc] init]; 132 #endif 125 133 sortControllerArray = [[NSMutableArray alloc] init]; 126 134 activeSortController = nil; … … 1161 1169 //Create a new metaContact is we didn't find one. 1162 1170 if (!metaContact) { 1171 AILogWithSignature(@"New metacontact to group %@ on %@", UIDsArray, servicesArray); 1163 1172 metaContact = [self metaContactWithObjectID:nil]; 1164 1173 } … … 1209 1218 //Create a new metaContact is we didn't find one. 1210 1219 if (!metaContact) { 1220 AILogWithSignature(@"New metacontact to group %@", contactsToGroupArray); 1211 1221 metaContact = [self metaContactWithObjectID:nil]; 1212 1222 } … … 1424 1434 - (void)registerListObjectObserver:(id <AIListObjectObserver>)inObserver 1425 1435 { 1436 //Add the observer 1437 #ifdef CONTACT_OBSERVER_MEMORY_MANAGEMENT_DEBUG 1426 1438 AILogWithSignature(@"%@", inObserver); 1427 1428 //Add the observer 1439 [contactObservers addObject:inObserver]; 1440 #else 1429 1441 [contactObservers addObject:[NSValue valueWithNonretainedObject:inObserver]]; 1442 #endif 1430 1443 1431 1444 //Let the new observer process all existing objects … … 1435 1448 - (void)unregisterListObjectObserver:(id)inObserver 1436 1449 { 1450 #ifdef CONTACT_OBSERVER_MEMORY_MANAGEMENT_DEBUG 1437 1451 AILogWithSignature(@"%@", inObserver); 1438 1452 [contactObservers removeObjectIdenticalTo:inObserver]; 1453 unregisterListObjectObserverCalled = YES; 1454 #else 1439 1455 [contactObservers removeObject:[NSValue valueWithNonretainedObject:inObserver]]; 1456 #endif 1440 1457 } 1441 1458 … … 1508 1525 { 1509 1526 NSMutableSet *attrChange = nil; 1527 1528 #ifdef CONTACT_OBSERVER_MEMORY_MANAGEMENT_DEBUG 1529 NSObject <AIListObjectObserver> *observer; 1530 1531 //Let our observers know 1532 int i; 1533 for (i = 0; i < [contactObservers count]; i++) { 1534 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 1535 NSSet *newKeys; 1536 1537 observer = [contactObservers objectAtIndex:i]; 1538 1539 if ([observer retainCount] == 1) { 1540 NSString *observerDescription = [observer description]; 1541 1542 /* This observer is fully released except for our retention (contactObservers plus its copy), which wouldn't happen without 1543 * CONTACT_OBSERVER_MEMORY_MANAGEMENT_DEBUG defined. That -might- be an error... except that it 1544 * might remove itself as an observer in its dealloc method, which is fine if it actually happens. 1545 */ 1546 unregisterListObjectObserverCalled = NO; 1547 [contactObservers removeObjectIdenticalTo:observer]; 1548 1549 //observer will have deallocated. It should have called removeContactObserver in the process. If it didn't, that's bad. 1550 if (!unregisterListObjectObserverCalled) { 1551 AILogWithSignature(@"%@ failed at removing itself as a contact observer! This would be fatal in a release build!", observerDescription); 1552 NSLog(@"%@ failed at removing itself as a contact observer! This would be fatal in a release build!", observerDescription); 1553 NSAssert1(FALSE, @"%@ failed at removing itself as a contact observer! This would be fatal in a release build!", observerDescription); 1554 } else { 1555 AILogWithSignature(@"All is well after the dealloc of %@", observerDescription); 1556 } 1557 } else { 1558 if ((newKeys = [observer updateListObject:inObject keys:modifiedKeys silent:silent])) { 1559 if (!attrChange) attrChange = [[NSMutableSet alloc] init]; 1560 [attrChange unionSet:newKeys]; 1561 } 1562 } 1563 [pool release]; 1564 } 1565 #else 1510 1566 NSEnumerator *enumerator; 1511 1567 NSValue *observerValue; … … 1525 1581 [pool release]; 1526 1582 } 1527 1583 #endif 1528 1584 //Send out the notification for other observers 1529 1585 [[adium notificationCenter] postNotificationName:ListObject_StatusChanged … … 1539 1595 { 1540 1596 NSEnumerator *enumerator = [contactObservers objectEnumerator]; 1597 #ifdef CONTACT_OBSERVER_MEMORY_MANAGEMENT_DEBUG 1598 id <AIListObjectObserver> observer; 1599 1600 while ((observer = [enumerator nextObject])) { 1601 [observer updateListObject:inObject keys:nil silent:YES]; 1602 } 1603 #else 1541 1604 NSValue *observerValue; 1542 1605 … … 1546 1609 [observer updateListObject:inObject keys:nil silent:YES]; 1547 1610 } 1611 #endif 1548 1612 } 1549 1613