make clearing global history work again (bug 236033) and try to prevent

exceptions when history doesn't provide all the data.
This commit is contained in:
pinkerton%aol.net 2004-03-03 04:43:16 +00:00
Родитель 4201608a7c
Коммит 3465a89814
4 изменённых файлов: 25 добавлений и 16 удалений

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

@ -200,7 +200,7 @@ const int kDefaultExpireDays = 9;
//
- (IBAction)clearGlobalHistory:(id)sender
{
nsCOMPtr<nsIBrowserHistory> hist ( do_GetService("@mozilla.org/browser/global-history;1") );
nsCOMPtr<nsIBrowserHistory> hist ( do_GetService("@mozilla.org/browser/global-history;2") );
if ( hist )
hist->RemoveAllPages();
}

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

@ -282,7 +282,7 @@ static NSArray* sToolbarDefaults = nil;
NSArray* returnTypes = [NSArray arrayWithObjects:NSStringPboardType, nil];
[NSApp registerServicesMenuSendTypes:sendTypes returnTypes:returnTypes];
nsCOMPtr<nsIBrowserHistory> globalHist = do_GetService("@mozilla.org/browser/global-history;1");
nsCOMPtr<nsIBrowserHistory> globalHist = do_GetService("@mozilla.org/browser/global-history;2");
mGlobalHistory = globalHist;
if ( mGlobalHistory )
NS_ADDREF(mGlobalHistory);

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

@ -87,7 +87,7 @@
- (void)deleteFromGecko;
{
nsCOMPtr<nsIBrowserHistory> historyService = do_GetService("@mozilla.org/browser/global-history;1");
nsCOMPtr<nsIBrowserHistory> historyService = do_GetService("@mozilla.org/browser/global-history;2");
if( !historyService )
return;
@ -136,25 +136,30 @@
if( !mChildNodes ) [self nativeBuildChildCache];
HistoryItem * firstChild = [mChildNodes objectAtIndex:0];
if( [firstChild nativeIsExpandable] ) {
HistoryItem * grandChild = [firstChild nativeChildAtIndex:0];
//is it a leaf node?
if( ![grandChild nativeIsExpandable] )
return YES;
if ( [mChildNodes count] ) {
HistoryItem * firstChild = [mChildNodes objectAtIndex:0];
if( [firstChild nativeIsExpandable] ) {
HistoryItem * grandChild = [firstChild nativeChildAtIndex:0];
//is it a leaf node?
if( ![grandChild nativeIsExpandable] )
return YES;
}
}
return NO;
}
- (HistoryItem*)childAtIndex:(int)index;
{
if( !kFlattenHistory )
if ( !kFlattenHistory )
return [super childAtIndex:index];
if( ![self shouldUseGrandChildNodes] )
if ( ![self shouldUseGrandChildNodes] )
return [super childAtIndex:index];
if( !mGrandChildNodes )
if ( !mGrandChildNodes )
[self buildGrandChildCache];
return [mGrandChildNodes objectAtIndex:index];
HistoryItem* child = nil;
if (index < [mGrandChildNodes count])
child = [mGrandChildNodes objectAtIndex:index];
return child;
}
- (int)numChildren;
@ -191,7 +196,8 @@
int grandChildCount = [curChild nativeNumChildren];
for( int j=0; j < grandChildCount; j++ ) {
HistoryItem * curGrandChild = [curChild nativeChildAtIndex:j];
[grandChildNodes addObject:curGrandChild];
if (curGrandChild)
[grandChildNodes addObject:curGrandChild];
}
}
NSArray * sorted = [grandChildNodes sortedArrayUsingSelector:@selector(historyItemDateCompare:)];

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

@ -173,9 +173,12 @@
// 0- based
- (RDFItem*)childAtIndex:(int)index;
{
if( !mChildNodes )
RDFItem* child = nil;
if (!mChildNodes)
[self buildChildCache];
return [mChildNodes objectAtIndex:index];
if (index < [mChildNodes count])
child = [mChildNodes objectAtIndex:index];
return child;
}
- (void)buildChildCache;