diff --git a/toolkit/components/places/src/History.cpp b/toolkit/components/places/src/History.cpp index cf4854ae70af..7d6e348deda1 100644 --- a/toolkit/components/places/src/History.cpp +++ b/toolkit/components/places/src/History.cpp @@ -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; } }