From 750efa7d51d97859f37e9e59065ba176d7520cce Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 20 Jul 2004 22:28:55 +0000 Subject: No need to use a weak ref for the observer, makes the single code easier. 2004-07-21 Marco Pesenti Gritti * embed/mozilla/EphySingle.cpp: * embed/mozilla/EphySingle.h: * embed/mozilla/mozilla-embed-single.cpp: No need to use a weak ref for the observer, makes the single code easier. --- ChangeLog | 9 +++++++++ embed/mozilla/EphySingle.cpp | 10 +++++----- embed/mozilla/EphySingle.h | 3 +-- embed/mozilla/mozilla-embed-single.cpp | 7 +------ 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index b28ca8336..ff6fa70b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-07-21 Marco Pesenti Gritti + + * embed/mozilla/EphySingle.cpp: + * embed/mozilla/EphySingle.h: + * embed/mozilla/mozilla-embed-single.cpp: + + No need to use a weak ref for the observer, + makes the single code easier. + 2004-07-20 Marco Pesenti Gritti * embed/mozilla/EphyHeaderSniffer.cpp: diff --git a/embed/mozilla/EphySingle.cpp b/embed/mozilla/EphySingle.cpp index 3c8fb67b6..065b886cf 100644 --- a/embed/mozilla/EphySingle.cpp +++ b/embed/mozilla/EphySingle.cpp @@ -39,7 +39,7 @@ #include #endif -NS_IMPL_ISUPPORTS2(EphySingle, nsIObserver, nsISupportsWeakReference) +NS_IMPL_ISUPPORTS1(EphySingle, nsIObserver) EphySingle::EphySingle() : mOwner(nsnull) @@ -54,10 +54,10 @@ EphySingle::Init (EphyEmbedSingle *aOwner) NS_ENSURE_TRUE (mObserverService, NS_ERROR_FAILURE); nsresult rv; - rv = mObserverService->AddObserver (this, "cookie-changed", PR_TRUE); - rv |= mObserverService->AddObserver (this, "cookie-rejected", PR_TRUE); - rv |= mObserverService->AddObserver (this, "perm-changed", PR_TRUE); - rv |= mObserverService->AddObserver (this, "network:offline-status-changed", PR_TRUE); + rv = mObserverService->AddObserver (this, "cookie-changed", PR_FALSE); + rv |= mObserverService->AddObserver (this, "cookie-rejected", PR_FALSE); + rv |= mObserverService->AddObserver (this, "perm-changed", PR_FALSE); + rv |= mObserverService->AddObserver (this, "network:offline-status-changed", PR_FALSE); NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE); mOwner = aOwner; diff --git a/embed/mozilla/EphySingle.h b/embed/mozilla/EphySingle.h index 5c47a5002..aff9de9a6 100644 --- a/embed/mozilla/EphySingle.h +++ b/embed/mozilla/EphySingle.h @@ -33,8 +33,7 @@ #include #include -class EphySingle : public nsIObserver, - public nsSupportsWeakReference +class EphySingle : public nsIObserver { public: NS_DECL_ISUPPORTS diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp index 0ee08f9d4..fb6f644e3 100644 --- a/embed/mozilla/mozilla-embed-single.cpp +++ b/embed/mozilla/mozilla-embed-single.cpp @@ -419,8 +419,7 @@ mozilla_init_observer (MozillaEmbedSingle *single) EphySingle *es; es = new EphySingle (); - nsCOMPtr guard = NS_STATIC_CAST (nsIObserver *, es); - if (!guard) return; + NS_ADDREF (single->priv->mSingleObserver = es); nsresult rv; rv = es->Init (EPHY_EMBED_SINGLE (single)); @@ -429,8 +428,6 @@ mozilla_init_observer (MozillaEmbedSingle *single) g_warning ("Failed to initialise EphySingle!\n"); return; } - - NS_ADDREF (single->priv->mSingleObserver = es); } static gboolean @@ -511,8 +508,6 @@ mozilla_embed_single_dispose (GObject *object) { single->priv->mSingleObserver->Detach (); NS_RELEASE (single->priv->mSingleObserver); - delete single->priv->mSingleObserver; - single->priv->mSingleObserver = nsnull; } } -- cgit v1.2.3