зеркало из 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()
|
History::~History()
|
||||||
{
|
{
|
||||||
gService = NULL;
|
gService = NULL;
|
||||||
|
#ifdef DEBUG
|
||||||
|
if (mObservers.IsInitialized()) {
|
||||||
|
NS_ASSERTION(mObservers.Count() == 0,
|
||||||
|
"Not all Links were removed before we disappear!");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -241,18 +247,24 @@ History::RegisterVisitedCallback(nsIURI* aURI,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtain our array of observers for this URI.
|
// Obtain our array of observers for this URI.
|
||||||
|
#ifdef DEBUG
|
||||||
|
bool keyAlreadyExists = !!mObservers.GetEntry(aURI);
|
||||||
|
#endif
|
||||||
KeyClass* key = mObservers.PutEntry(aURI);
|
KeyClass* key = mObservers.PutEntry(aURI);
|
||||||
NS_ENSURE_TRUE(key, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(key, NS_ERROR_OUT_OF_MEMORY);
|
||||||
ObserverArray& observers = key->array;
|
ObserverArray& observers = key->array;
|
||||||
|
|
||||||
if (observers.IsEmpty()) {
|
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
|
// 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
|
// Links wanting to know about this URI. Therefore, we should query the
|
||||||
// database now.
|
// database now.
|
||||||
nsresult rv = VisitedQuery::Start(aURI);
|
nsresult rv = VisitedQuery::Start(aURI);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
// Curses - unregister and return failure.
|
// Remove our array from the hashtable so we don't keep it around.
|
||||||
(void)UnregisterVisitedCallback(aURI, aLink);
|
mObservers.RemoveEntry(aURI);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче