fixed regression in mailnews caused by my last change. Need to support weak references both while adding AND while notifying... d'oh! a=pchen@netscape.com

This commit is contained in:
dougt%netscape.com 2001-10-20 02:07:33 +00:00
Родитель 6f1159ecf7
Коммит 5301a3ad28
1 изменённых файлов: 14 добавлений и 0 удалений

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

@ -45,6 +45,9 @@
#include "nsObserverService.h" #include "nsObserverService.h"
#include "nsObserverList.h" #include "nsObserverList.h"
#include "nsHashtable.h" #include "nsHashtable.h"
#include "nsIWeakReference.h"
#define NS_WEAK_OBSERVERS
static NS_DEFINE_CID(kObserverServiceCID, NS_OBSERVERSERVICE_CID); static NS_DEFINE_CID(kObserverServiceCID, NS_OBSERVERSERVICE_CID);
@ -211,6 +214,17 @@ NS_IMETHODIMP nsObserverService::NotifyObservers( nsISupports *aSubject,
nsCOMPtr<nsIObserver> observer = do_QueryInterface(observerRef); nsCOMPtr<nsIObserver> observer = do_QueryInterface(observerRef);
if ( observer ) if ( observer )
observer->Observe( aSubject, aTopic, someData ); observer->Observe( aSubject, aTopic, someData );
#ifdef NS_WEAK_OBSERVERS
else
{ // check for weak reference.
nsCOMPtr<nsIWeakReference> weakRef = do_QueryInterface(observerRef);
if ( weakRef )
weakRef->QueryReferent(NS_GET_IID(nsIObserver), getter_AddRefs(observer));
if ( observer )
observer->Observe( aSubject, aTopic, someData );
}
#endif
} }
return NS_OK; return NS_OK;
} }