From 678223acb062ff6383eb2250e628d138baf3303a Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Tue, 22 Nov 2005 15:48:10 +0000 Subject: [PATCH] If a binding stops being the most-derived binding for a content node before we've fired its constructor, remove it from the constructors-to-be-fired list. Bug 317265, r+sr=bryner git-svn-id: svn://10.0.0.236/trunk@185132 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/xbl/src/nsBindingManager.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mozilla/content/xbl/src/nsBindingManager.cpp b/mozilla/content/xbl/src/nsBindingManager.cpp index 6c4170e2588..27b84bf2105 100644 --- a/mozilla/content/xbl/src/nsBindingManager.cpp +++ b/mozilla/content/xbl/src/nsBindingManager.cpp @@ -344,6 +344,17 @@ nsBindingManager::SetBinding(nsIContent* aContent, nsXBLBinding* aBinding) return NS_ERROR_OUT_OF_MEMORY; } + // After this point, aBinding will be the most-derived binding for aContent. + // If we already have a binding for aContent in our table, make sure to + // remove it from the attached stack. Otherwise we might end up firing its + // constructor twice (if aBinding inherits from it) or firing its constructor + // after aContent has been deleted (if aBinding is null and the content node + // dies before we process mAttachedStack). + nsXBLBinding* oldBinding = mBindingTable.GetWeak(aContent); + if (oldBinding && mAttachedStack.RemoveElement(oldBinding)) { + NS_RELEASE(oldBinding); + } + PRBool result = PR_TRUE; if (aBinding) {