From cc2e070cb399d4581df590127f964add66aa0124 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Sun, 27 Jun 2004 11:53:34 +0000 Subject: EphySingle needs to implement nsISupportsWeakReference. 2004-06-27 Christian Persch * embed/mozilla/EphySingle.cpp: * embed/mozilla/EphySingle.h: * embed/mozilla/mozilla-embed-single.cpp: EphySingle needs to implement nsISupportsWeakReference. 2004-06-26 Christian Persch --- embed/mozilla/EphySingle.cpp | 10 +++++++--- embed/mozilla/EphySingle.h | 4 +++- embed/mozilla/mozilla-embed-single.cpp | 20 ++++++++++++-------- 3 files changed, 22 insertions(+), 12 deletions(-) (limited to 'embed/mozilla') diff --git a/embed/mozilla/EphySingle.cpp b/embed/mozilla/EphySingle.cpp index e059b5344..b8814d4e6 100644 --- a/embed/mozilla/EphySingle.cpp +++ b/embed/mozilla/EphySingle.cpp @@ -34,7 +34,7 @@ #include #include -NS_IMPL_ISUPPORTS1(EphySingle, nsIObserver) +NS_IMPL_ISUPPORTS2(EphySingle, nsIObserver, nsISupportsWeakReference) EphySingle::EphySingle() : mOwner(nsnull) @@ -45,8 +45,6 @@ EphySingle::EphySingle() nsresult EphySingle::Init (EphyEmbedSingle *aOwner) { - LOG ("EphySingle::Init") - mObserverService = do_GetService ("@mozilla.org/observer-service;1"); NS_ENSURE_TRUE (mObserverService, NS_ERROR_FAILURE); @@ -59,6 +57,8 @@ EphySingle::Init (EphyEmbedSingle *aOwner) mOwner = aOwner; + LOG ("EphySingle::Init") + return NS_OK; } @@ -129,6 +129,8 @@ NS_IMETHODIMP EphySingle::Observe(nsISupports *aSubject, { nsresult rv = NS_OK; + LOG ("EphySingle::Observe topic %s", aTopic) + if (strcmp (aTopic, "cookie-changed") == 0) { /* "added" */ @@ -221,6 +223,8 @@ NS_IMETHODIMP EphySingle::Observe(nsISupports *aSubject, rv = NS_ERROR_FAILURE; } + LOG ("EphySingle::Observe %s", NS_SUCCEEDED (rv) ? "success" : "FAILURE") + return rv; } diff --git a/embed/mozilla/EphySingle.h b/embed/mozilla/EphySingle.h index ac884ffc0..5c47a5002 100644 --- a/embed/mozilla/EphySingle.h +++ b/embed/mozilla/EphySingle.h @@ -29,10 +29,12 @@ #include #include #include +#include #include #include -class EphySingle : public nsIObserver +class EphySingle : public nsIObserver, + public nsSupportsWeakReference { public: NS_DECL_ISUPPORTS diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp index 33f14737e..5882b3fae 100644 --- a/embed/mozilla/mozilla-embed-single.cpp +++ b/embed/mozilla/mozilla-embed-single.cpp @@ -414,18 +414,21 @@ mozilla_init_chrome (void) static void mozilla_init_observer (MozillaEmbedSingle *single) { - EphySingle *observer; + EphySingle *es; - observer = new EphySingle (); + es = new EphySingle (); + nsCOMPtr guard = NS_STATIC_CAST (nsIObserver *, es); + if (!guard) return; - if (observer) + nsresult rv; + rv = es->Init (EPHY_EMBED_SINGLE (single)); + if (NS_FAILED (rv)) { - nsresult rv; - rv = observer->Init (EPHY_EMBED_SINGLE (single)); - if (NS_FAILED (rv)) return; - - NS_ADDREF (single->priv->mSingleObserver = observer); + g_warning ("Failed to initialise EphySingle!\n"); + return; } + + NS_ADDREF (single->priv->mSingleObserver = es); } static gboolean @@ -506,6 +509,7 @@ 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