Fix bug 295752: crash when going to show history by site. Fixed init method signatures for the history tree builders.

This commit is contained in:
smfr%smfr.org 2005-05-28 01:10:24 +00:00
Родитель 0ea8a4266e
Коммит c9f11ba2a9
1 изменённых файлов: 29 добавлений и 13 удалений

Просмотреть файл

@ -100,7 +100,8 @@ static int HistoryItemSort(id firstItem, id secondItem, void* context)
}
// sets up the tree and sorts it
- (id)initWithDataSource:(HistoryDataSource*)inDataSource items:(NSArray*)items sortSelector:(SEL)sortSelector descending:(BOOL)descending;
- (id)initWithDataSource:(HistoryDataSource*)inDataSource sortSelector:(SEL)sortSelector descending:(BOOL)descending;
- (void)buildTree;
- (HistoryItem*)rootItem;
- (HistoryItem*)addItem:(HistorySiteItem*)item;
@ -158,6 +159,7 @@ static int HistoryItemSort(id firstItem, id secondItem, void* context)
- (void)rebuildSearchResults;
- (void)sortSearchResults;
- (NSArray*)historyItems;
- (HistorySiteItem*)itemWithIdentifier:(NSString*)identifier;
- (NSString*)relativeDataStringForDate:(NSDate*)date;
@ -203,15 +205,13 @@ static int HistoryItemSort(id firstItem, id secondItem, void* context)
@implementation HistoryTreeBuilder
- (id)initWithDataSource:(HistoryDataSource*)inDataSource items:(NSArray*)items sortSelector:(SEL)sortSelector descending:(BOOL)descending
- (id)initWithDataSource:(HistoryDataSource*)inDataSource sortSelector:(SEL)sortSelector descending:(BOOL)descending
{
if ((self = [super init]))
{
mDataSource = inDataSource; // not retained
mSortSelector = sortSelector;
mSortDescending = descending;
[self buildTreeWithItems:items];
}
return self;
}
@ -222,6 +222,11 @@ static int HistoryItemSort(id firstItem, id secondItem, void* context)
[super dealloc];
}
- (void)buildTree
{
[self buildTreeWithItems:[mDataSource historyItems]];
}
- (HistoryItem*)rootItem
{
return mRootItem;
@ -285,6 +290,14 @@ static int HistoryItemSort(id firstItem, id secondItem, void* context)
@implementation HistoryBySiteTreeBuilder
- (id)initWithDataSource:(HistoryDataSource*)inDataSource sortSelector:(SEL)sortSelector descending:(BOOL)descending
{
if ((self = [super initWithDataSource:inDataSource sortSelector:sortSelector descending:descending]))
{
}
return self;
}
- (void)dealloc
{
[mSiteDictionary release];
@ -373,15 +386,11 @@ static int HistoryItemSort(id firstItem, id secondItem, void* context)
@implementation HistoryByDateTreeBuilder
- (id)initWithItems:(NSArray*)items sortSelector:(SEL)sortSelector descending:(BOOL)descending
- (id)initWithDataSource:(HistoryDataSource*)inDataSource sortSelector:(SEL)sortSelector descending:(BOOL)descending
{
if ((self = [super init]))
if ((self = [super initWithDataSource:inDataSource sortSelector:sortSelector descending:descending]))
{
mSortSelector = sortSelector;
mSortDescending = descending;
[self setupDateCategories];
[self buildTreeWithItems:items];
}
return self;
}
@ -714,11 +723,13 @@ NS_IMPL_ISUPPORTS1(nsHistoryObserver, nsIHistoryObserver);
mTreeBuilder = nil;
if ([mCurrentViewIdentifier isEqualToString:kHistoryViewFlat])
mTreeBuilder = [[HistoryTreeBuilder alloc] initWithItems:mHistoryItems sortSelector:[self selectorForSortColumn] descending:mSortDescending];
mTreeBuilder = [[HistoryTreeBuilder alloc] initWithDataSource:self sortSelector:[self selectorForSortColumn] descending:mSortDescending];
else if ([mCurrentViewIdentifier isEqualToString:kHistoryViewBySite])
mTreeBuilder = [[HistoryBySiteTreeBuilder alloc] initWithItems:mHistoryItems sortSelector:[self selectorForSortColumn] descending:mSortDescending];
mTreeBuilder = [[HistoryBySiteTreeBuilder alloc] initWithDataSource:self sortSelector:[self selectorForSortColumn] descending:mSortDescending];
else // default to by date
mTreeBuilder = [[HistoryByDateTreeBuilder alloc] initWithItems:mHistoryItems sortSelector:[self selectorForSortColumn] descending:mSortDescending];
mTreeBuilder = [[HistoryByDateTreeBuilder alloc] initWithDataSource:self sortSelector:[self selectorForSortColumn] descending:mSortDescending];
[mTreeBuilder buildTree];
[self notifyChanged:nil itemOnly:NO];
}
@ -921,6 +932,11 @@ NS_IMPL_ISUPPORTS1(nsHistoryObserver, nsIHistoryObserver);
return @selector(compareLastVisitDate:sortDescending:);
}
- (NSArray*)historyItems
{
return mHistoryItems;
}
- (HistorySiteItem*)itemWithIdentifier:(NSString*)identifier
{
return [mHistoryItemsDictionary objectForKey:identifier];