bug 349228 - Use appropriate observers in comparison in CalDAV. Patch by Bruno Browning <browning@uwalumni.com>, r=lilmatt, jminta

git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@215653 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mattwillis%gmail.com
2006-11-22 12:52:35 +00:00
parent ab4305bbc9
commit 8b7b87cbf9
2 changed files with 29 additions and 3 deletions

View File

@@ -145,9 +145,13 @@ function getUUID() {
}
/** Due to a bug in js-wrapping, normal == comparison can fail when we
* have 2 calIItemBases. Use this function to force them both to get wrapped
* have 2 objects. Use these functions to force them both to get wrapped
* the same way, allowing for normal comparison.
*/
/**
* calIItemBase comparer
*/
function compareItems(aItem, aOtherItem) {
var sip1 = Cc["@mozilla.org/supports-interface-pointer;1"].
createInstance(Ci.nsISupportsInterfacePointer);
@@ -161,6 +165,28 @@ function compareItems(aItem, aOtherItem) {
return sip1.data == sip2.data;
}
/**
* Generic object comparer
* Use to compare two objects which are not of type calIItemBase, in order
* to avoid the js-wrapping issues mentioned above.
*
* @param aObject first object to be compared
* @param aOtherObject second object to be compared
* @param aIID IID to use in comparison
*/
function compareObjects(aObject, aOtherObject, aIID) {
var sip1 = Cc["@mozilla.org/supports-interface-pointer;1"].
createInstance(Ci.nsISupportsInterfacePointer);
sip1.data = aObject;
sip1.dataIID = aIID;
var sip2 = Cc["@mozilla.org/supports-interface-pointer;1"].
createInstance(Ci.nsISupportsInterfacePointer);
sip2.data = aOtherObject;
sip2.dataIID = aIID;
return sip1.data == sip2.data;
}
/****
**** debug code
****/

View File

@@ -188,8 +188,8 @@ calDavCalendar.prototype = {
// void addObserver( in calIObserver observer );
addObserver: function (aObserver, aItemFilter) {
for each (obs in aObserver) {
if (obs == aObserver) {
for each (obs in this.mObservers) {
if (compareObjects(obs, aObserver, Ci.calIObserver)) {
return;
}
}