diff options
-rw-r--r-- | ChangeLog | 28 | ||||
-rw-r--r-- | configure.in | 7 | ||||
-rw-r--r-- | embed/ephy-favicon-cache.c | 2 | ||||
-rw-r--r-- | embed/ephy-history.c | 61 | ||||
-rw-r--r-- | lib/ephy-file-helpers.c | 57 | ||||
-rw-r--r-- | lib/ephy-file-helpers.h | 4 | ||||
-rw-r--r-- | lib/ephy-node.c | 56 | ||||
-rw-r--r-- | lib/ephy-node.h | 2 | ||||
-rw-r--r-- | lib/ephy-state.c | 2 | ||||
-rw-r--r-- | lib/widgets/ephy-tree-model-node.c | 5 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks-export.c | 2 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks.c | 4 | ||||
-rw-r--r-- | src/ephy-automation.c | 2 |
13 files changed, 185 insertions, 47 deletions
@@ -1,3 +1,31 @@ +2003-05-25 Marco Pesenti Gritti <marco@it.gnome.org> + + * configure.in: + * embed/ephy-favicon-cache.c: (ephy_favicon_cache_save): + * embed/ephy-history.c: (ephy_history_save), (hosts_removed_cb), + (pages_removed_cb), (unref_empty_host), + (page_removed_from_host_cb), (connect_page_removed_from_host), + (ephy_history_init), (ephy_history_add_host): + * lib/ephy-file-helpers.c: (ephy_file_save_xml): + * lib/ephy-file-helpers.h: + * lib/ephy-node.c: (callback), (ephy_node_emit_signal), + (real_remove_child), (ephy_node_dispose): + * lib/ephy-node.h: + * lib/ephy-state.c: (ephy_states_save): + * lib/widgets/ephy-tree-model-node.c: (root_child_removed_cb): + * src/bookmarks/ephy-bookmarks-export.c: + (ephy_bookmarks_export_rdf): + * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_save), + (bookmarks_removed_cb), (topics_removed_cb): + + Try to fix node removal problems. I cant repro crashes ... + but they are quite hard to reproduce. + Use a save_xml helper that is low disk safe. + + * src/ephy-automation.c: (impl_ephy_automation_loadurl): + + Use OPEN_PAGE when an url is passed + 2003-05-25 Xan Lopez <xan@masilla.org> * embed/downloader-view.c: (controls_info_foreach), diff --git a/configure.in b/configure.in index 242789b84..b52ff8fa1 100644 --- a/configure.in +++ b/configure.in @@ -180,8 +180,8 @@ MOZILLA_VERSION="`$PKG_CONFIG --modversion mozilla-gtkmozembed`" dnl allow user to override the autodetected mozilla version dnl - without arguments for cvs head AC_ARG_WITH(mozilla-snapshot, - AC_HELP_STRING([--with-mozilla-snapshot@<:@=1.3|1.4a|trunk@:>@], - [Whether to try building against mozilla 1.3|1.4a|trunk + AC_HELP_STRING([--with-mozilla-snapshot@<:@=1.3|1.3.1|1.4a|trunk@:>@], + [Whether to try building against mozilla 1.3|1.3.1|1.4a|trunk snapshot. @<:@guessed@:>@]), [autodetect=" (guessed: $MOZILLA_VERSION)"; MOZILLA_VERSION="$withval"]) @@ -189,13 +189,14 @@ AC_MSG_RESULT($MOZILLA_VERSION$autodetect) case "$MOZILLA_VERSION" in 1.3) MOZILLA_SNAPSHOT=6 ;; +1.3.1) MOZILLA_SNAPSHOT=6 ;; "") MOZILLA_SNAPSHOT=7 ;; 1.4a) MOZILLA_SNAPSHOT=7 ;; 1.4b) MOZILLA_SNAPSHOT=7 ;; trunk) MOZILLA_SNAPSHOT=7 ;; *) AC_ERROR([ ***************************************************************************** -Epiphany can be built using mozilla 1.3, 1.4a, 1.4b or trunk snapshot, but the +Epiphany can be built using mozilla 1.3, 1.3.1, 1.4a, 1.4b or trunk snapshot, but the version available is $MOZILLA_VERSION. When using mozilla trunk snapshot successful build is not guaranteed due to diff --git a/embed/ephy-favicon-cache.c b/embed/ephy-favicon-cache.c index 1391c5f5c..275348607 100644 --- a/embed/ephy-favicon-cache.c +++ b/embed/ephy-favicon-cache.c @@ -253,7 +253,7 @@ ephy_favicon_cache_save (EphyFaviconCache *eb) } ephy_node_thaw (eb->priv->icons); - xmlSaveFormatFile (eb->priv->xml_file, doc, 1); + ephy_file_save_xml (eb->priv->xml_file, doc); xmlFreeDoc (doc); } diff --git a/embed/ephy-history.c b/embed/ephy-history.c index c9541c618..525e13326 100644 --- a/embed/ephy-history.c +++ b/embed/ephy-history.c @@ -309,7 +309,7 @@ ephy_history_save (EphyHistory *eb) } ephy_node_thaw (eb->priv->pages); - xmlSaveFormatFile (eb->priv->xml_file, doc, 1); + ephy_file_save_xml (eb->priv->xml_file, doc); xmlFreeDoc(doc); } @@ -330,6 +330,7 @@ hosts_added_cb (EphyNode *node, static void hosts_removed_cb (EphyNode *node, EphyNode *child, + guint old_index, EphyHistory *eb) { g_static_rw_lock_writer_lock (eb->priv->hosts_hash_lock); @@ -357,29 +358,15 @@ pages_added_cb (EphyNode *node, static void pages_removed_cb (EphyNode *node, EphyNode *child, + guint old_index, EphyHistory *eb) { - EphyNode *host; - int host_id; - int children; - g_static_rw_lock_writer_lock (eb->priv->pages_hash_lock); g_hash_table_remove (eb->priv->pages_hash, ephy_node_get_property_string (child, EPHY_NODE_PAGE_PROP_LOCATION)); g_static_rw_lock_writer_unlock (eb->priv->pages_hash_lock); - - host_id = ephy_node_get_property_int (child, EPHY_NODE_PAGE_PROP_HOST_ID); - host = ephy_node_db_get_node_from_id (eb->priv->db, host_id); - children = ephy_node_get_n_children (host); - - LOG ("Check host children: %d", children) - - if (children == 0) - { - ephy_node_unref (host); - } } static gboolean @@ -391,6 +378,39 @@ periodic_save_cb (EphyHistory *eh) return TRUE; } +static gboolean +unref_empty_host (EphyNode *node) +{ + ephy_node_unref (node); + + return FALSE; +} + +static void +page_removed_from_host_cb (EphyNode *node, + EphyNode *child, + guint old_index, + EphyHistory *eb) +{ + if (ephy_node_get_n_children (node) == 0) + { + g_idle_add ((GSourceFunc)unref_empty_host, node); + } +} + +static void +connect_page_removed_from_host (char *url, + EphyNode *node, + EphyHistory *eb) +{ + if (node == eb->priv->pages) return; + + ephy_node_signal_connect_object (node, + EPHY_NODE_CHILD_REMOVED, + (EphyNodeCallback) page_removed_from_host_cb, + G_OBJECT (eb)); +} + static void ephy_history_init (EphyHistory *eb) { @@ -460,6 +480,10 @@ ephy_history_init (EphyHistory *eb) ephy_history_load (eb); ephy_history_emit_data_changed (eb); + g_hash_table_foreach (eb->priv->hosts_hash, + (GHFunc) connect_page_removed_from_host, + eb); + /* setup the periodic history saving callback */ eb->priv->autosave_timeout = g_timeout_add (HISTORY_SAVE_INTERVAL, @@ -614,6 +638,11 @@ ephy_history_add_host (EphyHistory *eh, EphyNode *page) if (!host) { host = ephy_node_new (eh->priv->db); + ephy_node_signal_connect_object (host, + EPHY_NODE_CHILD_REMOVED, + (EphyNodeCallback) page_removed_from_host_cb, + G_OBJECT (eh)); + g_value_init (&value, G_TYPE_STRING); g_value_set_string (&value, host_name); ephy_node_set_property (host, EPHY_NODE_PAGE_PROP_TITLE, diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c index 6ca68be28..6577bc06b 100644 --- a/lib/ephy-file-helpers.c +++ b/lib/ephy-file-helpers.c @@ -365,3 +365,60 @@ ephy_file_find (const char *path, ephy_find_file_recursive (path, fname, &ret, 0, maxdepth); return ret; } + +gboolean +ephy_file_save_xml (const char *xml_file, xmlDocPtr doc) +{ + char *tmp_file; + char *old_file; + gboolean old_exist; + gboolean retval = TRUE; + + tmp_file = g_strconcat (xml_file, ".tmp", NULL); + old_file = g_strconcat (xml_file, ".old", NULL); + + if (!xmlSaveFormatFile (tmp_file, doc, 1)) + { + g_warning ("Failed to write XML data to %s", tmp_file); + goto failed; + } + + old_exist = g_file_test (xml_file, G_FILE_TEST_EXISTS); + + if (old_exist) + { + if (rename (xml_file, old_file) < 0) + { + g_warning ("Failed to rename %s to %s", xml_file, old_file); + retval = FALSE; + goto failed; + } + } + + if (rename (tmp_file, xml_file) < 0) + { + g_warning ("Failed to rename %s to %s", tmp_file, xml_file); + + if (rename (old_file, xml_file) < 0) + { + g_warning ("Failed to restore %s from %s", xml_file, tmp_file); + } + retval = FALSE; + goto failed; + } + + if (old_exist) + { + if (unlink (old_file) < 0) + { + g_warning ("Failed to delete old file %s", old_file); + } + } + + failed: + g_free (old_file); + g_free (tmp_file); + + return retval; +} + diff --git a/lib/ephy-file-helpers.h b/lib/ephy-file-helpers.h index 0fb24b254..cd29f9ec4 100644 --- a/lib/ephy-file-helpers.h +++ b/lib/ephy-file-helpers.h @@ -22,6 +22,7 @@ #define EPHY_FILE_HELPERS_H #include <glib.h> +#include <libxml/tree.h> G_BEGIN_DECLS @@ -46,6 +47,9 @@ GSList *ephy_file_find (const char *path, const char *fname, gint maxdepth); +gboolean ephy_file_save_xml (const char *xml_file, + xmlDocPtr doc); + G_END_DECLS #endif /* EPHY_FILE_HELPERS_H */ diff --git a/lib/ephy-node.c b/lib/ephy-node.c index 660b234ee..35c7f87d6 100644 --- a/lib/ephy-node.c +++ b/lib/ephy-node.c @@ -129,10 +129,21 @@ callback (long id, EphyNodeSignalData *data, gpointer *user_data) case EPHY_NODE_CHILD_ADDED: case EPHY_NODE_CHILD_CHANGED: - case EPHY_NODE_CHILD_REMOVED: data->callback (data->node, va_arg (valist, EphyNode *), data->data); break; + case EPHY_NODE_CHILD_REMOVED: + { + EphyNode *node; + guint last_index; + + node = va_arg (valist, EphyNode *); + last_index = va_arg (valist, guint); + + data->callback (data->node, node, last_index, data->data); + } + break; + case EPHY_NODE_CHILDREN_REORDERED: data->callback (data->node, va_arg (valist, int *), data->data); break; @@ -152,6 +163,7 @@ ephy_node_emit_signal (EphyNode *node, EphyNodeSignalType type, ...) g_hash_table_foreach (node->signals, (GHFunc) callback, data); + va_end (valist); } @@ -197,6 +209,9 @@ real_remove_child (EphyNode *node, if (remove_from_parent) { guint i; + guint old_index; + + old_index = node_info->index; g_ptr_array_remove_index (node->children, node_info->index); @@ -216,21 +231,20 @@ real_remove_child (EphyNode *node, g_static_rw_lock_writer_unlock (borked_node->lock); } + + write_lock_to_read_lock (node); + write_lock_to_read_lock (child); + + ephy_node_emit_signal (node, EPHY_NODE_CHILD_REMOVED, child, old_index); + + read_lock_to_write_lock (node); + read_lock_to_write_lock (child); } if (remove_from_child) { g_hash_table_remove (child->parents, GINT_TO_POINTER (node->id)); } - - write_lock_to_read_lock (node); - write_lock_to_read_lock (child); - - ephy_node_emit_signal (node, EPHY_NODE_CHILD_REMOVED, child); - - read_lock_to_write_lock (node); - read_lock_to_write_lock (child); - } static void @@ -267,19 +281,8 @@ ephy_node_dispose (EphyNode *node) { guint i; - _ephy_node_db_remove_id (node->db, node->id); - lock_gdk (); - /* remove from DAG */ - g_hash_table_foreach (node->parents, - (GHFunc) remove_child, - node); - - g_hash_table_foreach (node->signals, - (GHFunc) unref_signal_objects, - node); - for (i = 0; i < node->children->len; i++) { EphyNode *child; @@ -292,10 +295,21 @@ ephy_node_dispose (EphyNode *node) g_static_rw_lock_writer_unlock (child->lock); } + /* remove from DAG */ + g_hash_table_foreach (node->parents, + (GHFunc) remove_child, + node); + g_static_rw_lock_writer_unlock (node->lock); ephy_node_emit_signal (node, EPHY_NODE_DESTROYED); + g_hash_table_foreach (node->signals, + (GHFunc) unref_signal_objects, + node); + + _ephy_node_db_remove_id (node->db, node->id); + unlock_gdk (); } diff --git a/lib/ephy-node.h b/lib/ephy-node.h index 846d5fa41..5a6853f4e 100644 --- a/lib/ephy-node.h +++ b/lib/ephy-node.h @@ -34,7 +34,7 @@ typedef enum EPHY_NODE_RESTORED, /* RBNode *node */ EPHY_NODE_CHILD_ADDED, /* RBNode *node, RBNode *child */ EPHY_NODE_CHILD_CHANGED, /* RBNode *node, RBNode *child */ - EPHY_NODE_CHILD_REMOVED, /* RBNode *node, RBNode *child */ + EPHY_NODE_CHILD_REMOVED, /* RBNode *node, RBNode *child, guint old_index */ EPHY_NODE_CHILDREN_REORDERED /* RBNode *node, int *new_order */ } EphyNodeSignalType; diff --git a/lib/ephy-state.c b/lib/ephy-state.c index 1df65a642..a23533ae4 100644 --- a/lib/ephy-state.c +++ b/lib/ephy-state.c @@ -109,7 +109,7 @@ ephy_states_save (void) } ephy_node_thaw (states); - xmlSaveFormatFile (xml_file, doc, 1); + ephy_file_save_xml (xml_file, doc); g_free (xml_file); } diff --git a/lib/widgets/ephy-tree-model-node.c b/lib/widgets/ephy-tree-model-node.c index 73c654712..cf92167d2 100644 --- a/lib/widgets/ephy-tree-model-node.c +++ b/lib/widgets/ephy-tree-model-node.c @@ -66,6 +66,7 @@ static gboolean ephy_tree_model_node_iter_parent (GtkTreeModel *tree_model, static void ephy_tree_model_node_tree_model_init (GtkTreeModelIface *iface); static void root_child_removed_cb (EphyNode *node, EphyNode *child, + guint old_index, EphyTreeModelNode *model); static void root_child_added_cb (EphyNode *node, EphyNode *child, @@ -656,11 +657,13 @@ ephy_tree_model_node_iter_from_node (EphyTreeModelNode *model, static void root_child_removed_cb (EphyNode *node, EphyNode *child, + guint old_index, EphyTreeModelNode *model) { GtkTreePath *path; - path = get_path_real (model, child); + path = gtk_tree_path_new (); + gtk_tree_path_append_index (path, old_index); gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path); gtk_tree_path_free (path); } diff --git a/src/bookmarks/ephy-bookmarks-export.c b/src/bookmarks/ephy-bookmarks-export.c index 3403a1931..e17a67dc0 100644 --- a/src/bookmarks/ephy-bookmarks-export.c +++ b/src/bookmarks/ephy-bookmarks-export.c @@ -137,6 +137,6 @@ ephy_bookmarks_export_rdf (EphyBookmarks *bookmarks, } ephy_node_thaw (bmks); - xmlSaveFormatFile (filename, doc, 1); + ephy_file_save_xml (filename, doc); xmlFreeDoc(doc); } diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c index 9e7c9dacc..b83c29888 100644 --- a/src/bookmarks/ephy-bookmarks.c +++ b/src/bookmarks/ephy-bookmarks.c @@ -339,7 +339,7 @@ ephy_bookmarks_save (EphyBookmarks *eb) } ephy_node_thaw (eb->priv->bookmarks); - xmlSaveFormatFile (eb->priv->xml_file, doc, 1); + ephy_file_save_xml (eb->priv->xml_file, doc); xmlFreeDoc(doc); /* Export bookmarks in rdf */ @@ -482,6 +482,7 @@ bookmarks_changed_cb (EphyNode *node, static void bookmarks_removed_cb (EphyNode *node, EphyNode *child, + guint old_index, EphyBookmarks *eb) { long id; @@ -544,6 +545,7 @@ update_topics_list (EphyNode *bookmark, const char *list) static void topics_removed_cb (EphyNode *node, EphyNode *child, + guint old_index, EphyBookmarks *eb) { long id; diff --git a/src/ephy-automation.c b/src/ephy-automation.c index 96ed5f2d3..0fbea13bb 100644 --- a/src/ephy-automation.c +++ b/src/ephy-automation.c @@ -120,7 +120,7 @@ impl_ephy_automation_loadurl (PortableServer_Servant _servant, } else { - flags |= EPHY_NEW_TAB_NEW_PAGE; + flags |= EPHY_NEW_TAB_OPEN_PAGE; } if (open_in_new_tab) |