aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla/mozilla-embed.cpp
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-05-11 06:04:27 +0800
committerChristian Persch <chpe@src.gnome.org>2004-05-11 06:04:27 +0800
commit1e3f9396348313d869e2c21d4af9edd19c80fc53 (patch)
tree910535825ea3cd194030f19fa9e18fefacfddf2e /embed/mozilla/mozilla-embed.cpp
parent6369e4883e19a85d144b066ec9c4e01330613ba4 (diff)
downloadgsoc2013-epiphany-1e3f9396348313d869e2c21d4af9edd19c80fc53.tar
gsoc2013-epiphany-1e3f9396348313d869e2c21d4af9edd19c80fc53.tar.gz
gsoc2013-epiphany-1e3f9396348313d869e2c21d4af9edd19c80fc53.tar.bz2
gsoc2013-epiphany-1e3f9396348313d869e2c21d4af9edd19c80fc53.tar.lz
gsoc2013-epiphany-1e3f9396348313d869e2c21d4af9edd19c80fc53.tar.xz
gsoc2013-epiphany-1e3f9396348313d869e2c21d4af9edd19c80fc53.tar.zst
gsoc2013-epiphany-1e3f9396348313d869e2c21d4af9edd19c80fc53.zip
Destroy the EphyBrowser in destroy handler, but delete it only on
2004-05-11 Christian Persch <chpe@cvs.gnome.org> * embed/mozilla/EphyBrowser.cpp: * embed/mozilla/mozilla-embed.cpp: Destroy the EphyBrowser in destroy handler, but delete it only on finalize. Make public EphyBrowser methods safe for calling after Destroy. Part of bug #142184.
Diffstat (limited to 'embed/mozilla/mozilla-embed.cpp')
-rw-r--r--embed/mozilla/mozilla-embed.cpp66
1 files changed, 43 insertions, 23 deletions
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index 4452fa334..e5e14e98c 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -54,6 +54,7 @@
static void mozilla_embed_class_init (MozillaEmbedClass *klass);
static void mozilla_embed_init (MozillaEmbed *gs);
static void mozilla_embed_destroy (GtkObject *object);
+static void mozilla_embed_finalize (GObject *object);
static void ephy_embed_iface_init (EphyEmbedIface *iface);
static void mozilla_embed_connect_signals (MozillaEmbed *membed);
@@ -244,6 +245,7 @@ mozilla_embed_class_init (MozillaEmbedClass *klass)
parent_class = (GObjectClass *) g_type_class_peek_parent (klass);
object_class->constructor = mozilla_embed_constructor;
+ object_class->finalize = mozilla_embed_finalize;
gtk_object_class->destroy = mozilla_embed_destroy;
@@ -257,22 +259,8 @@ mozilla_embed_init (MozillaEmbed *embed)
{
embed->priv = MOZILLA_EMBED_GET_PRIVATE (embed);
embed->priv->browser = new EphyBrowser ();
- embed->priv->security_state = -1;
+ embed->priv->security_state = STATE_IS_UNKNOWN;
- mozilla_embed_connect_signals (embed);
-}
-
-gpointer
-_mozilla_embed_get_ephy_browser (MozillaEmbed *embed)
-{
- g_return_val_if_fail (embed->priv->browser != NULL, NULL);
-
- return embed->priv->browser;
-}
-
-static void
-mozilla_embed_connect_signals (MozillaEmbed *embed)
-{
g_signal_connect_object (G_OBJECT (embed), "location",
G_CALLBACK (mozilla_embed_location_changed_cb),
embed, (GConnectFlags) 0);
@@ -296,6 +284,14 @@ mozilla_embed_connect_signals (MozillaEmbed *embed)
embed, (GConnectFlags) 0);
}
+gpointer
+_mozilla_embed_get_ephy_browser (MozillaEmbed *embed)
+{
+ g_return_val_if_fail (embed->priv->browser != NULL, NULL);
+
+ return embed->priv->browser;
+}
+
static void
mozilla_embed_destroy (GtkObject *object)
{
@@ -304,14 +300,28 @@ mozilla_embed_destroy (GtkObject *object)
if (embed->priv->browser)
{
embed->priv->browser->Destroy();
- delete embed->priv->browser;
- embed->priv->browser = NULL;
}
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
+mozilla_embed_finalize (GObject *object)
+{
+ MozillaEmbed *embed = MOZILLA_EMBED (object);
+
+ if (embed->priv->browser)
+ {
+ delete embed->priv->browser;
+ embed->priv->browser = nsnull;
+ }
+
+ embed->priv->request = nsnull;
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
impl_load_url (EphyEmbed *embed,
const char *url)
{
@@ -451,7 +461,10 @@ impl_go_up (EphyEmbed *embed)
char *parent_uri;
uri = ephy_embed_get_location (embed, TRUE);
- g_return_if_fail (uri != NULL);
+ if (uri == NULL)
+ {
+ return;
+ }
parent_uri = mozilla_embed_get_uri_parent (uri);
g_free (uri);
@@ -519,8 +532,7 @@ impl_reload (EphyEmbed *embed,
mflags = GTK_MOZ_EMBED_FLAG_RELOADBYPASSPROXYANDCACHE;
}
- gtk_moz_embed_reload (GTK_MOZ_EMBED(embed),
- mflags);
+ gtk_moz_embed_reload (GTK_MOZ_EMBED(embed), mflags);
}
static void
@@ -595,9 +607,16 @@ impl_shistory_get_nth (EphyEmbed *embed,
rv = mpriv->browser->GetSHTitleAtIndex(nth, &title);
- *aTitle = g_strdup (NS_ConvertUTF16toUTF8(title).get());
+ if (title)
+ {
+ *aTitle = g_strdup (NS_ConvertUTF16toUTF8(title).get());
- nsMemory::Free (title);
+ nsMemory::Free (title);
+ }
+ else
+ {
+ *aTitle = NULL;
+ }
}
static int
@@ -628,7 +647,8 @@ impl_get_security_level (EphyEmbed *embed,
{
nsresult result;
- g_return_if_fail (description != NULL || level != NULL);
+ g_return_if_fail (description != NULL && level != NULL);
+
*description = NULL;
*level = STATE_IS_UNKNOWN;