Bug 345445 - prevent duplicate observers from being added. r=jwatt, sr=roc

This commit is contained in:
tor%cs.brown.edu 2006-07-25 15:31:09 +00:00
Родитель 9ad1b722bc
Коммит 908ba8a1a7
1 изменённых файлов: 9 добавлений и 0 удалений

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

@ -102,6 +102,15 @@ nsSVGValue::AddObserver(nsISVGValueObserver* observer)
{
nsIWeakReference* wr = NS_GetWeakReference(observer);
if (!wr) return NS_ERROR_FAILURE;
// Prevent duplicate observers - needed because geometry can attempt
// to add itself as an observer of a paint server for both the
// stroke and fill. Safe, as on a style change we remove both, as
// the change notification isn't fine grained, and re-add as
// appropriate.
if (mObservers.IndexOf((void*)wr) >= 0)
return NS_OK;
mObservers.AppendElement((void*)wr);
return NS_OK;
}