зеркало из https://github.com/mozilla/gecko-dev.git
Bug 549882 - ###!!! ASSERTION: Trying to unregister a node that wasn't registered!
Also adds some assertions to make sure we do not leak the observer arrays. r=dietrich
This commit is contained in:
Родитель
d1cb40d001
Коммит
00424b6359
|
@ -163,6 +163,12 @@ History::History()
|
|||
History::~History()
|
||||
{
|
||||
gService = NULL;
|
||||
#ifdef DEBUG
|
||||
if (mObservers.IsInitialized()) {
|
||||
NS_ASSERTION(mObservers.Count() == 0,
|
||||
"Not all Links were removed before we disappear!");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -241,18 +247,24 @@ History::RegisterVisitedCallback(nsIURI* aURI,
|
|||
}
|
||||
|
||||
// Obtain our array of observers for this URI.
|
||||
#ifdef DEBUG
|
||||
bool keyAlreadyExists = !!mObservers.GetEntry(aURI);
|
||||
#endif
|
||||
KeyClass* key = mObservers.PutEntry(aURI);
|
||||
NS_ENSURE_TRUE(key, NS_ERROR_OUT_OF_MEMORY);
|
||||
ObserverArray& observers = key->array;
|
||||
|
||||
if (observers.IsEmpty()) {
|
||||
NS_ASSERTION(!keyAlreadyExists,
|
||||
"An empty key was kept around in our hashtable!");
|
||||
|
||||
// We are the first Link node to ask about this URI, or there are no pending
|
||||
// Links wanting to know about this URI. Therefore, we should query the
|
||||
// database now.
|
||||
nsresult rv = VisitedQuery::Start(aURI);
|
||||
if (NS_FAILED(rv)) {
|
||||
// Curses - unregister and return failure.
|
||||
(void)UnregisterVisitedCallback(aURI, aLink);
|
||||
// Remove our array from the hashtable so we don't keep it around.
|
||||
mObservers.RemoveEntry(aURI);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче