зеркало из https://github.com/mozilla/pjs.git
Fix memory leaks. Add API's to ObserverManager to allow objects to
Unregister
This commit is contained in:
Родитель
d10c5c6553
Коммит
219920426f
|
@ -30,7 +30,10 @@
|
|||
#include "nsXPFCNotificationStateCommand.h"
|
||||
#include "nsCalFetchEventsCommand.h"
|
||||
#include "nsXPFCModelUpdateCommand.h"
|
||||
#include "nsIXPFCObserver.h"
|
||||
#include "nsIXPFCSubject.h"
|
||||
|
||||
static NS_DEFINE_IID(kCXPFCSubjectIID, NS_IXPFC_SUBJECT_IID);
|
||||
static NS_DEFINE_IID(kICalendarModelIID, NS_ICALENDAR_MODEL_IID);
|
||||
static NS_DEFINE_IID(kIModelIID, NS_IMODEL_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
@ -41,6 +44,7 @@ static NS_DEFINE_IID(kCXPFCObserverManagerCID, NS_XPFC_OBSERVERMANAGER_CID);
|
|||
static NS_DEFINE_IID(kIXPFCObserverManagerIID, NS_IXPFC_OBSERVERMANAGER_IID);
|
||||
static NS_DEFINE_IID(kXPFCObserverIID, NS_IXPFC_OBSERVER_IID);
|
||||
static NS_DEFINE_IID(kXPFCCommandReceiverIID, NS_IXPFC_COMMANDRECEIVER_IID);
|
||||
static NS_DEFINE_IID(kCXPFCObserverIID, NS_IXPFC_OBSERVER_IID);
|
||||
|
||||
nsCalendarModel::nsCalendarModel(nsISupports* outer)
|
||||
{
|
||||
|
@ -97,16 +101,14 @@ NS_IMPL_RELEASE(nsCalendarModel)
|
|||
|
||||
nsCalendarModel::~nsCalendarModel()
|
||||
{
|
||||
// XXX
|
||||
#if 0
|
||||
nsIXPFCObserverManager* om;
|
||||
|
||||
nsServiceManager::GetService(kCXPFCObserverManagerCID, kIXPFCObserverManagerIID, (nsISupports**)&om);
|
||||
|
||||
nsresult res = om->Unregister((nsISupports *)(void*)this);
|
||||
|
||||
nsIXPFCObserver * observer = (nsIXPFCObserver *) this;
|
||||
nsIXPFCSubject * subject = (nsIXPFCSubject *) this;
|
||||
om->UnregisterSubject(subject);
|
||||
om->UnregisterObserver(observer);
|
||||
nsServiceManager::ReleaseService(kCXPFCObserverManagerCID, om);
|
||||
#endif
|
||||
|
||||
mCalendarUser = nsnull; // Do Not Release
|
||||
}
|
||||
|
||||
|
@ -314,5 +316,7 @@ nsresult nsCalendarModel :: Notify(nsIXPFCCommand * aCommand)
|
|||
|
||||
nsServiceManager::ReleaseService(kCXPFCObserverManagerCID, om);
|
||||
|
||||
NS_RELEASE(subject);
|
||||
|
||||
return(res);
|
||||
}
|
||||
|
|
|
@ -149,7 +149,29 @@ nsCalXMLContentSink::nsCalXMLContentSink() : nsIHTMLContentSink()
|
|||
|
||||
nsCalXMLContentSink::~nsCalXMLContentSink()
|
||||
{
|
||||
NS_RELEASE(mOrphanCanvasList);
|
||||
|
||||
if (mOrphanCanvasList != nsnull) {
|
||||
|
||||
nsIIterator * iterator;
|
||||
|
||||
mOrphanCanvasList->CreateIterator(&iterator);
|
||||
iterator->Init();
|
||||
|
||||
nsIXPFCCanvas * item;
|
||||
|
||||
while(!(iterator->IsDone()))
|
||||
{
|
||||
item = (nsIXPFCCanvas *) iterator->CurrentItem();
|
||||
NS_RELEASE(item);
|
||||
iterator->Next();
|
||||
}
|
||||
NS_RELEASE(iterator);
|
||||
|
||||
mOrphanCanvasList->RemoveAll();
|
||||
NS_RELEASE(mOrphanCanvasList);
|
||||
}
|
||||
|
||||
|
||||
NS_RELEASE(mTimeContextList);
|
||||
NS_RELEASE(mCanvasStack);
|
||||
|
||||
|
@ -351,6 +373,7 @@ NS_IMETHODIMP nsCalXMLContentSink::AddToHierarchy(nsIXMLParserObject& aObject, P
|
|||
if (parent == nsnull) {
|
||||
|
||||
mOrphanCanvasList->Append(canvas);
|
||||
NS_ADDREF(canvas);
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -361,6 +384,8 @@ NS_IMETHODIMP nsCalXMLContentSink::AddToHierarchy(nsIXMLParserObject& aObject, P
|
|||
if (aPush == PR_TRUE)
|
||||
mCanvasStack->Push(canvas);
|
||||
|
||||
NS_RELEASE(canvas);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -482,6 +507,8 @@ NS_IMETHODIMP nsCalXMLContentSink::AddLeaf(const nsIParserNode& aNode)
|
|||
|
||||
ConsumeAttributes(aNode,*object);
|
||||
|
||||
NS_RELEASE(object);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -646,34 +673,32 @@ NS_IMETHODIMP nsCalXMLContentSink::AddControl(const nsIParserNode& aNode)
|
|||
|
||||
child->Reparent(parent);
|
||||
|
||||
mOrphanCanvasList->Remove(child);
|
||||
|
||||
/*
|
||||
* Pass certain attributes to the parent canvas (layout, weightminor, weighmajor, etc...)
|
||||
*/
|
||||
nsresult res = child->QueryInterface(kIXMLParserObjectIID,(void**)&object);
|
||||
|
||||
if (NS_OK != res)
|
||||
return res;
|
||||
|
||||
for (i = 0; i < aNode.GetAttributeCount(); i++)
|
||||
if (NS_OK == res)
|
||||
{
|
||||
for (i = 0; i < aNode.GetAttributeCount(); i++)
|
||||
{
|
||||
|
||||
key = aNode.GetKeyAt(i);
|
||||
value = aNode.GetValueAt(i);
|
||||
key = aNode.GetKeyAt(i);
|
||||
value = aNode.GetValueAt(i);
|
||||
|
||||
key.StripChars("\"");
|
||||
value.StripChars("\"");
|
||||
key.StripChars("\"");
|
||||
value.StripChars("\"");
|
||||
|
||||
if (key.EqualsIgnoreCase(CAL_STRING_LAYOUT) || key.EqualsIgnoreCase(CAL_STRING_WEIGHTMAJOR) || key.EqualsIgnoreCase(CAL_STRING_WEIGHTMINOR))
|
||||
object->SetParameter(key,value);
|
||||
if (key.EqualsIgnoreCase(CAL_STRING_LAYOUT) || key.EqualsIgnoreCase(CAL_STRING_WEIGHTMAJOR) || key.EqualsIgnoreCase(CAL_STRING_WEIGHTMINOR))
|
||||
object->SetParameter(key,value);
|
||||
}
|
||||
|
||||
NS_RELEASE(object);
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_RELEASE(object);
|
||||
|
||||
return NS_OK;
|
||||
mOrphanCanvasList->Remove(child);
|
||||
NS_RELEASE(child);
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCalXMLContentSink::PushMark()
|
||||
|
|
|
@ -20,9 +20,17 @@
|
|||
#include "nsCalUICIID.h"
|
||||
#include "nsXPFCModelUpdateCommand.h"
|
||||
#include "nsXPFCToolkit.h"
|
||||
#include "nsIXPFCObserverManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIXPFCObserver.h"
|
||||
#include "nsIXPFCSubject.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kCalCanvasCID, NS_CAL_CANVAS_CID);
|
||||
static NS_DEFINE_IID(kCXPFCObserverManagerCID, NS_XPFC_OBSERVERMANAGER_CID);
|
||||
static NS_DEFINE_IID(kIXPFCObserverManagerIID, NS_IXPFC_OBSERVERMANAGER_IID);
|
||||
static NS_DEFINE_IID(kCXPFCObserverIID, NS_IXPFC_OBSERVER_IID);
|
||||
static NS_DEFINE_IID(kCXPFCSubjectIID, NS_IXPFC_SUBJECT_IID);
|
||||
|
||||
nsCalCanvas :: nsCalCanvas(nsISupports* outer) : nsXPFCCanvas(outer)
|
||||
{
|
||||
|
@ -32,6 +40,15 @@ nsCalCanvas :: nsCalCanvas(nsISupports* outer) : nsXPFCCanvas(outer)
|
|||
|
||||
nsCalCanvas :: ~nsCalCanvas()
|
||||
{
|
||||
nsIXPFCObserverManager* om;
|
||||
nsServiceManager::GetService(kCXPFCObserverManagerCID, kIXPFCObserverManagerIID, (nsISupports**)&om);
|
||||
|
||||
nsIXPFCObserver * observer = (nsIXPFCObserver *) this;
|
||||
|
||||
om->UnregisterObserver(observer);
|
||||
|
||||
nsServiceManager::ReleaseService(kCXPFCObserverManagerCID, om);
|
||||
|
||||
NS_IF_RELEASE(mUser);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,12 @@
|
|||
#include "nsxpfcCIID.h"
|
||||
#include "nsIXPFCObserverManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIXPFCObserver.h"
|
||||
#include "nsIXPFCSubject.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kCXPFCSubjectIID, NS_IXPFC_SUBJECT_IID);
|
||||
static NS_DEFINE_IID(kCXPFCObserverIID, NS_IXPFC_OBSERVER_IID);
|
||||
static NS_DEFINE_IID(kXPFCSubjectIID, NS_IXPFC_SUBJECT_IID);
|
||||
static NS_DEFINE_IID(kXPFCCommandIID, NS_IXPFC_COMMAND_IID);
|
||||
static NS_DEFINE_IID(kXPFCCommandCID, NS_XPFC_COMMAND_CID);
|
||||
|
@ -70,8 +74,11 @@ nsCalTimeContext :: ~nsCalTimeContext()
|
|||
|
||||
nsIXPFCObserverManager* om;
|
||||
nsServiceManager::GetService(kCXPFCObserverManagerCID, kIXPFCObserverManagerIID, (nsISupports**)&om);
|
||||
nsIXPFCObserver * observer = (nsIXPFCObserver *) this;
|
||||
nsIXPFCSubject * subject = (nsIXPFCSubject *) this;
|
||||
|
||||
om->Unregister((nsISupports*)(nsICalTimeContext*)this);
|
||||
om->UnregisterSubject(subject);
|
||||
om->UnregisterObserver(observer);
|
||||
|
||||
nsServiceManager::ReleaseService(kCXPFCObserverManagerCID, om);
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "nsxpfcCIID.h"
|
||||
#include "nsIXPFCObserverManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIXPFCObserver.h"
|
||||
#include "nsIXPFCSubject.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kCalContextControllerIID, NS_ICAL_CONTEXT_CONTROLLER_IID);
|
||||
|
@ -34,6 +36,8 @@ static NS_DEFINE_IID(kXPFCCommandIID, NS_IXPFC_COMMAND_IID);
|
|||
static NS_DEFINE_IID(kXPFCCommandCID, NS_XPFC_COMMAND_CID);
|
||||
static NS_DEFINE_IID(kCXPFCObserverManagerCID, NS_XPFC_OBSERVERMANAGER_CID);
|
||||
static NS_DEFINE_IID(kIXPFCObserverManagerIID, NS_IXPFC_OBSERVERMANAGER_IID);
|
||||
static NS_DEFINE_IID(kCXPFCObserverIID, NS_IXPFC_OBSERVER_IID);
|
||||
static NS_DEFINE_IID(kCXPFCSubjectIID, NS_IXPFC_SUBJECT_IID);
|
||||
|
||||
#define kNotFound -1
|
||||
|
||||
|
@ -48,6 +52,12 @@ nsCalContextController :: nsCalContextController(nsISupports * aOuter) : nsXPFCC
|
|||
|
||||
nsCalContextController :: ~nsCalContextController()
|
||||
{
|
||||
nsIXPFCObserverManager* om;
|
||||
nsServiceManager::GetService(kCXPFCObserverManagerCID, kIXPFCObserverManagerIID, (nsISupports**)&om);
|
||||
nsIXPFCSubject * subject = (nsIXPFCSubject *)this;
|
||||
om->UnregisterSubject(subject);
|
||||
nsServiceManager::ReleaseService(kCXPFCObserverManagerCID, om);
|
||||
|
||||
NS_IF_RELEASE(mDuration);
|
||||
}
|
||||
|
||||
|
|
|
@ -166,8 +166,11 @@ nsresult nsCalFactory::CreateInstance(nsISupports *aOuter,
|
|||
nsISupports *inst = nsnull;
|
||||
|
||||
if (mClassID.Equals(kCCalTimeContext)) {
|
||||
inst = (nsISupports *)(nsICalTimeContext *)new nsCalTimeContext();
|
||||
#if 0
|
||||
nsICalTimeContext * cc = (nsICalTimeContext *)new nsCalTimeContext();
|
||||
cc->QueryInterface(kISupportsIID,(void **)&inst);
|
||||
#endif
|
||||
}
|
||||
else if (mClassID.Equals(kCCalComponent)) {
|
||||
inst = (nsISupports *)new nsCalComponent();
|
||||
|
@ -185,72 +188,55 @@ nsresult nsCalFactory::CreateInstance(nsISupports *aOuter,
|
|||
inst = (nsISupports *)new nsCalNewModelCommand();
|
||||
}
|
||||
else if (mClassID.Equals(kCCalContextController)) {
|
||||
nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalContextController(aOuter);
|
||||
canvas->QueryInterface(kISupportsIID,(void **)&inst);
|
||||
inst = (nsISupports *)(nsIXPFCCanvas *)new nsCalContextController(aOuter);
|
||||
}
|
||||
else if (mClassID.Equals(kCCalTimebarContextController)) {
|
||||
nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalTimebarContextController(aOuter);
|
||||
canvas->QueryInterface(kISupportsIID,(void **)&inst);
|
||||
inst = (nsISupports *)(nsIXPFCCanvas *)new nsCalTimebarContextController(aOuter);
|
||||
}
|
||||
else if (mClassID.Equals(kCCalMonthContextController)) {
|
||||
nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalMonthContextController(aOuter);
|
||||
canvas->QueryInterface(kISupportsIID,(void **)&inst);
|
||||
inst = (nsISupports *)(nsIXPFCCanvas *)new nsCalMonthContextController(aOuter);
|
||||
}
|
||||
else if (mClassID.Equals(kCCalTimebarCanvas)) {
|
||||
nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalTimebarCanvas(aOuter);
|
||||
canvas->QueryInterface(kISupportsIID,(void **)&inst);
|
||||
inst = (nsISupports *)(nsIXPFCCanvas *)new nsCalTimebarCanvas(aOuter);
|
||||
}
|
||||
else if (mClassID.Equals(kCCalCanvas)) {
|
||||
nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalCanvas(aOuter);
|
||||
canvas->QueryInterface(kISupportsIID,(void **)&inst);
|
||||
inst = (nsISupports *)(nsIXPFCCanvas *)new nsCalCanvas(aOuter);
|
||||
}
|
||||
else if (mClassID.Equals(kCCalStatusCanvas)) {
|
||||
nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalStatusCanvas(aOuter);
|
||||
canvas->QueryInterface(kISupportsIID,(void **)&inst);
|
||||
inst = (nsISupports *)(nsIXPFCCanvas *)new nsCalStatusCanvas(aOuter);
|
||||
}
|
||||
else if (mClassID.Equals(kCCalCommandCanvas)) {
|
||||
nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalCommandCanvas(aOuter);
|
||||
canvas->QueryInterface(kISupportsIID,(void **)&inst);
|
||||
inst = (nsISupports *)(nsIXPFCCanvas *)new nsCalCommandCanvas(aOuter);
|
||||
}
|
||||
else if (mClassID.Equals(kCCalTimebarComponentCanvas)) {
|
||||
nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalTimebarComponentCanvas(aOuter);
|
||||
canvas->QueryInterface(kISupportsIID,(void **)&inst);
|
||||
inst = (nsISupports *)(nsIXPFCCanvas *)new nsCalTimebarComponentCanvas(aOuter);
|
||||
}
|
||||
else if (mClassID.Equals(kCCalTodoComponentCanvas)) {
|
||||
nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalTodoComponentCanvas(aOuter);
|
||||
canvas->QueryInterface(kISupportsIID,(void **)&inst);
|
||||
inst = (nsISupports *)(nsIXPFCCanvas *)new nsCalTodoComponentCanvas(aOuter);
|
||||
}
|
||||
else if (mClassID.Equals(kCCalTimebarHeading)) {
|
||||
nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalTimebarHeading(aOuter);
|
||||
canvas->QueryInterface(kISupportsIID,(void **)&inst);
|
||||
inst = (nsISupports *)(nsIXPFCCanvas *)new nsCalTimebarHeading(aOuter);
|
||||
}
|
||||
else if (mClassID.Equals(kCCalTimebarUserHeading)) {
|
||||
nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalTimebarUserHeading(aOuter);
|
||||
canvas->QueryInterface(kISupportsIID,(void **)&inst);
|
||||
inst = (nsISupports *)(nsIXPFCCanvas *)new nsCalTimebarUserHeading(aOuter);
|
||||
}
|
||||
else if (mClassID.Equals(kCCalTimebarTimeHeading)) {
|
||||
nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalTimebarTimeHeading(aOuter);
|
||||
canvas->QueryInterface(kISupportsIID,(void **)&inst);
|
||||
inst = (nsISupports *)(nsIXPFCCanvas *)new nsCalTimebarTimeHeading(aOuter);
|
||||
}
|
||||
else if (mClassID.Equals(kCCalTimebarScale)) {
|
||||
nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalTimebarScale(aOuter);
|
||||
canvas->QueryInterface(kISupportsIID,(void **)&inst);
|
||||
inst = (nsISupports *)(nsIXPFCCanvas *)new nsCalTimebarScale(aOuter);
|
||||
}
|
||||
else if (mClassID.Equals(kCCalMultiDayViewCanvas)) {
|
||||
nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalMultiDayViewCanvas(aOuter);
|
||||
canvas->QueryInterface(kISupportsIID,(void **)&inst);
|
||||
inst = (nsISupports *)(nsIXPFCCanvas *)new nsCalMultiDayViewCanvas(aOuter);
|
||||
}
|
||||
else if (mClassID.Equals(kCCalMultiUserViewCanvas)) {
|
||||
nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalMultiUserViewCanvas(aOuter);
|
||||
canvas->QueryInterface(kISupportsIID,(void **)&inst);
|
||||
inst = (nsISupports *)(nsIXPFCCanvas *)new nsCalMultiUserViewCanvas(aOuter);
|
||||
}
|
||||
else if (mClassID.Equals(kCCalDayViewCanvas)) {
|
||||
nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalDayViewCanvas(aOuter);
|
||||
canvas->QueryInterface(kISupportsIID,(void **)&inst);
|
||||
inst = (nsISupports *)(nsIXPFCCanvas *)new nsCalDayViewCanvas(aOuter);
|
||||
}
|
||||
else if (mClassID.Equals(kCCalMonthViewCanvas)) {
|
||||
nsXPFCCanvas * canvas = (nsXPFCCanvas *)new nsCalMonthViewCanvas(aOuter);
|
||||
canvas->QueryInterface(kISupportsIID,(void **)&inst);
|
||||
inst = (nsISupports *)(nsIXPFCCanvas *)new nsCalMonthViewCanvas(aOuter);
|
||||
}
|
||||
else if (mClassID.Equals(kCCalToolkit)) {
|
||||
inst = (nsISupports *)(nsICalToolkit *)new nsCalToolkit();
|
||||
|
|
|
@ -2016,21 +2016,23 @@ nsEventStatus nsXPFCCanvas::Action(nsIXPFCCommand * aCommand)
|
|||
}
|
||||
|
||||
NS_RELEASE(methodinvoker_command);
|
||||
|
||||
/*
|
||||
* Just paint ourselves for now
|
||||
*/
|
||||
|
||||
nsRect bounds;
|
||||
|
||||
GetView()->GetBounds(bounds);
|
||||
|
||||
bounds.x = 0;
|
||||
bounds.y = 0;
|
||||
|
||||
gXPFCToolkit->GetViewManager()->UpdateView(GetView(), bounds, NS_VMREFRESH_AUTO_DOUBLE_BUFFER | NS_VMREFRESH_NO_SYNC);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Just paint ourselves for now
|
||||
*/
|
||||
|
||||
nsRect bounds;
|
||||
|
||||
GetView()->GetBounds(bounds);
|
||||
|
||||
bounds.x = 0;
|
||||
bounds.y = 0;
|
||||
|
||||
gXPFCToolkit->GetViewManager()->UpdateView(GetView(), bounds, NS_VMREFRESH_AUTO_DOUBLE_BUFFER | NS_VMREFRESH_NO_SYNC);
|
||||
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ public:
|
|||
NS_IMETHOD Unregister(nsIXPFCSubject * aSubject, nsIXPFCObserver * aObserver);
|
||||
NS_IMETHOD Notify(nsIXPFCSubject * aSubject, nsIXPFCCommand * aCommand);
|
||||
NS_IMETHOD RegisterForCommandState(nsIXPFCObserver * aObserver, nsCommandState aCommandState);
|
||||
NS_IMETHOD UnregisterSubject(nsIXPFCSubject * aSubject);
|
||||
NS_IMETHOD UnregisterObserver(nsIXPFCObserver * aObserver);
|
||||
|
||||
private:
|
||||
NS_METHOD CheckForCommandStateNotification(nsIXPFCObserver * aObserver);
|
||||
|
|
|
@ -49,6 +49,8 @@ public:
|
|||
NS_IMETHOD Notify(nsIXPFCSubject * aSubject, nsIXPFCCommand * aCommand) = 0;
|
||||
|
||||
NS_IMETHOD RegisterForCommandState(nsIXPFCObserver * aObserver, nsCommandState aCommandState) = 0;
|
||||
NS_IMETHOD UnregisterSubject(nsIXPFCSubject * aSubject) = 0;
|
||||
NS_IMETHOD UnregisterObserver(nsIXPFCObserver * aObserver) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -183,6 +183,8 @@ nsresult nsXPFCObserverManager::Unregister(nsIXPFCSubject * aSubject, nsIXPFCObs
|
|||
/*
|
||||
* We need to loop through looking for a match of both and then remove them
|
||||
*/
|
||||
listunregister:
|
||||
|
||||
nsIIterator * iterator;
|
||||
|
||||
mList->CreateIterator(&iterator);
|
||||
|
@ -198,6 +200,9 @@ nsresult nsXPFCObserverManager::Unregister(nsIXPFCSubject * aSubject, nsIXPFCObs
|
|||
if (item->subject == aSubject && item->observer == aObserver)
|
||||
{
|
||||
mList->Remove((nsComponent)item);
|
||||
delete item;
|
||||
NS_RELEASE(iterator);
|
||||
goto listunregister;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -211,6 +216,16 @@ nsresult nsXPFCObserverManager::Unregister(nsIXPFCSubject * aSubject, nsIXPFCObs
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsXPFCObserverManager::UnregisterSubject(nsIXPFCSubject * aSubject)
|
||||
{
|
||||
return (Unregister((nsISupports*)aSubject));
|
||||
}
|
||||
|
||||
nsresult nsXPFCObserverManager::UnregisterObserver(nsIXPFCObserver * aObserver)
|
||||
{
|
||||
return (Unregister((nsISupports*)aObserver));
|
||||
}
|
||||
|
||||
/*
|
||||
* If an arbitrary object is passed in to unregister, we want to
|
||||
* remove it from all lists containing it as either a subject OR
|
||||
|
@ -225,9 +240,13 @@ nsresult nsXPFCObserverManager::Unregister(nsISupports * aSubjectObserver)
|
|||
* See which interfaces the passed in object supports
|
||||
*/
|
||||
|
||||
nsIXPFCObserver * observer;
|
||||
nsIXPFCSubject * subject;
|
||||
//XXX We really want to QueryInterface here ...
|
||||
|
||||
nsIXPFCObserver * observer = (nsIXPFCObserver *)aSubjectObserver;
|
||||
nsIXPFCSubject * subject = (nsIXPFCSubject *)aSubjectObserver;
|
||||
|
||||
|
||||
#if 0
|
||||
nsresult res = aSubjectObserver->QueryInterface(kCXPFCObserverIID, (void**)observer);
|
||||
|
||||
if (NS_OK != res)
|
||||
|
@ -247,10 +266,12 @@ nsresult nsXPFCObserverManager::Unregister(nsISupports * aSubjectObserver)
|
|||
NS_IF_RELEASE(observer);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
/*
|
||||
* We need to loop through looking for a match of both and then remove them
|
||||
*/
|
||||
listdelete:
|
||||
|
||||
nsIIterator * iterator;
|
||||
|
||||
mList->CreateIterator(&iterator);
|
||||
|
@ -266,7 +287,9 @@ nsresult nsXPFCObserverManager::Unregister(nsISupports * aSubjectObserver)
|
|||
if (item->subject == subject || item->observer == observer)
|
||||
{
|
||||
mList->Remove((nsComponent)item);
|
||||
break;
|
||||
delete item;
|
||||
NS_RELEASE(iterator);
|
||||
goto listdelete;
|
||||
}
|
||||
|
||||
iterator->Next();
|
||||
|
@ -276,8 +299,10 @@ nsresult nsXPFCObserverManager::Unregister(nsISupports * aSubjectObserver)
|
|||
|
||||
PR_ExitMonitor(monitor);
|
||||
|
||||
#if 0
|
||||
NS_IF_RELEASE(subject);
|
||||
NS_IF_RELEASE(observer);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче