[nautilus-actions] Fix the item counters when importing
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Fix the item counters when importing
- Date: Wed, 28 Oct 2009 23:59:43 +0000 (UTC)
commit cbe7a6cef1ab460dbf917b5f49385e698cbdcd04
Author: Pierre Wieser <pwieser trychlos org>
Date: Wed Oct 28 21:21:08 2009 +0100
Fix the item counters when importing
Revert a copy of the items list, and free it at end.
ChangeLog | 6 ++++++
src/common/na-object-item.c | 18 ++++++++++--------
src/nact/nact-iactions-list.c | 8 ++++----
3 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 802caff..7d6fca5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2009-10-28 Pierre Wieser <pwieser trychlos org>
+ * src/nact/nact-iactions-list.c (do_insert_items):
+ Take a copy before reverting the list, and free the copy at end.
+
+ * src/common/na-object-item.c (na_object_item_count_items):
+ Recurse into subitems before counting the current level.
+
* src/common/na-xml-writer.c:
* src/common/na-xml-writer.h:
(na_xml_writer_export): Returns a NULL filename if errors.
diff --git a/src/common/na-object-item.c b/src/common/na-object-item.c
index 04507d5..a0f4e08 100644
--- a/src/common/na-object-item.c
+++ b/src/common/na-object-item.c
@@ -147,9 +147,18 @@ na_object_item_count_items( GList *items, gint *menus, gint *actions, gint *prof
{
GList *it;
+ /*g_debug( "na_object_item_count_items: items=%p (count=%d), menus=%d, actions=%d, profiles=%d",
+ ( void * ) items, items ? g_list_length( items ) : 0, *menus, *actions, *profiles );*/
+
for( it = items ; it ; it = it->next ){
- /*g_debug( "na_object_item_count_items: item is %s", G_OBJECT_TYPE_NAME( it->data ));*/
+ if( recurse ){
+ if( NA_IS_OBJECT_ITEM( it->data )){
+ na_object_item_count_items(
+ NA_OBJECT_ITEM( it->data )->private->items, menus, actions, profiles, recurse );
+ }
+ }
+
if( NA_IS_OBJECT_MENU( it->data )){
*menus += 1;
} else if( NA_IS_OBJECT_ACTION( it->data )){
@@ -157,12 +166,5 @@ na_object_item_count_items( GList *items, gint *menus, gint *actions, gint *prof
} else if( NA_IS_OBJECT_PROFILE( it->data )){
*profiles += 1;
}
-
- if( recurse ){
- if( NA_IS_OBJECT_ITEM( it->data )){
- na_object_item_count_items(
- NA_OBJECT_ITEM( it->data )->private->items, menus, actions, profiles, recurse );
- }
- }
}
}
diff --git a/src/nact/nact-iactions-list.c b/src/nact/nact-iactions-list.c
index 37abca8..c762202 100644
--- a/src/nact/nact-iactions-list.c
+++ b/src/nact/nact-iactions-list.c
@@ -1268,7 +1268,7 @@ do_insert_items( GtkTreeView *treeview, GtkTreeModel *model, GList *items, GtkTr
*list_parents = NULL;
}
- reversed = g_list_reverse( items );
+ reversed = g_list_reverse( g_list_copy( items ));
for( it = reversed ; it ; it = it->next ){
@@ -1295,7 +1295,7 @@ do_insert_items( GtkTreeView *treeview, GtkTreeModel *model, GList *items, GtkTr
gtk_tree_path_free( inserted_path );
}
- /*g_list_free( reversed );*/
+ g_list_free( reversed );
}
static NAObject *
@@ -1350,8 +1350,8 @@ increment_counters( NactIActionsList *instance, IActionsListInstanceData *ialid,
static const gchar *thisfn = "nact_iactions_list_increment_counters";
gint menus, actions, profiles;
- g_debug( "%s: instance=%p, ialid=%p, items=%p",
- thisfn, ( void * ) instance, ( void * ) ialid, ( void * ) items );
+ g_debug( "%s: instance=%p, ialid=%p, items=%p (count=%d)",
+ thisfn, ( void * ) instance, ( void * ) ialid, ( void * ) items, items ? g_list_length( items ) : 0 );
menus = 0;
actions = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]