Register bookmarks datasource with RDF service *last*, because an other failure will leave the RDF service with a dangling pointer. Also, add assertion if we're unable to create a timer, because this is an *extremely* common platform porting error. r=rjc

This commit is contained in:
waterson%netscape.com 2000-07-09 23:49:41 +00:00
Родитель 902b10802f
Коммит 34c01f23ce
1 изменённых файлов: 8 добавлений и 4 удалений

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

@ -1922,10 +1922,6 @@ nsBookmarksService::Init()
rv = bm_AddRefGlobals();
if (NS_FAILED(rv)) return(rv);
// register this as a named data source with the RDF service
rv = gRDF->RegisterDataSource(this, PR_FALSE);
if (NS_FAILED(rv)) return rv;
/* create a URL for the string resource file */
nsCOMPtr<nsIIOService> pNetService;
if (NS_SUCCEEDED(rv = nsServiceManager::GetService(kIOServiceCID, NS_GET_IID(nsIIOService),
@ -2005,11 +2001,19 @@ nsBookmarksService::Init()
{
busySchedule = PR_FALSE;
mTimer = do_CreateInstance("component://netscape/timer", &rv);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a timer");
if (NS_FAILED(rv)) return rv;
mTimer->Init(nsBookmarksService::FireTimer, this, BOOKMARK_TIMEOUT, NS_PRIORITY_LOWEST, NS_TYPE_REPEATING_SLACK);
// Note: don't addref "this" as we'll cancel the timer in the nsBookmarkService destructor
}
// register this as a named data source with the RDF
// service. Do this *last*, because if Init() fails, then the
// object will be destroyed (leaving the RDF service with a
// dangling pointer).
rv = gRDF->RegisterDataSource(this, PR_FALSE);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}