зеркало из https://github.com/mozilla/gecko-dev.git
fix 101143 r=dp, sr=waterson shutdown observer skipped if previous observer removes itself upon shutdown notification
This commit is contained in:
Родитель
13d79feabe
Коммит
100dafd417
|
@ -224,6 +224,7 @@ NS_IMETHODIMP nsObserverService::Notify( nsISupports *aSubject,
|
||||||
rv = observers->First();
|
rv = observers->First();
|
||||||
// Continue until error or end of list.
|
// Continue until error or end of list.
|
||||||
while ( observers->IsDone() != NS_OK && NS_SUCCEEDED(rv) ) {
|
while ( observers->IsDone() != NS_OK && NS_SUCCEEDED(rv) ) {
|
||||||
|
PRBool advanceToNext = PR_TRUE;
|
||||||
// Get current item (observer).
|
// Get current item (observer).
|
||||||
nsISupports *base;
|
nsISupports *base;
|
||||||
rv = observers->CurrentItem( &base );
|
rv = observers->CurrentItem( &base );
|
||||||
|
@ -234,13 +235,19 @@ NS_IMETHODIMP nsObserverService::Notify( nsISupports *aSubject,
|
||||||
if ( NS_SUCCEEDED( rv ) && observer ) {
|
if ( NS_SUCCEEDED( rv ) && observer ) {
|
||||||
// Tell the observer what's up.
|
// Tell the observer what's up.
|
||||||
observer->Observe( aSubject, aTopic, someData );
|
observer->Observe( aSubject, aTopic, someData );
|
||||||
|
nsCOMPtr <nsISupports> currentItem;
|
||||||
|
observers->CurrentItem(getter_AddRefs(currentItem));
|
||||||
|
// check if the current item has changed, because the
|
||||||
|
// observer removed the old current item.
|
||||||
|
advanceToNext = (currentItem == base);
|
||||||
// Release the observer.
|
// Release the observer.
|
||||||
observer->Release();
|
observer->Release();
|
||||||
}
|
}
|
||||||
NS_IF_RELEASE(base);
|
NS_IF_RELEASE(base);
|
||||||
}
|
}
|
||||||
// Go on to next observer in list.
|
// Go on to next observer in list.
|
||||||
rv = observers->Next();
|
if (advanceToNext)
|
||||||
|
rv = observers->Next();
|
||||||
}
|
}
|
||||||
// Release the observer list.
|
// Release the observer list.
|
||||||
observers->Release();
|
observers->Release();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче