Re: Problem when adding a folder to the folder store tree model



Sergio Villar Senin wrote:
> Hi,
> 
> when you create a folder under some folder that has the same name than
> other folder in other account, then the folder is added to the model to
> the first folder found with the same name. The reason is this portion of
> code in tny-gtk-folder-store-tree-model.c:951

Find attached a patch that fixes this problem by checking the id of the
folder's account.

Br

Index: tny-gtk-folder-store-tree-model.c
===================================================================
--- tny-gtk-folder-store-tree-model.c	(revision 3227)
+++ tny-gtk-folder-store-tree-model.c	(working copy)
@@ -949,12 +949,33 @@
 		found = TRUE;
 
 	if (!found) {
-		if (fol && TNY_IS_FOLDER (fol))
+		TnyAccount *maccount = NULL, *saccount = NULL;
+		const gchar *ma_id = NULL, *sa_id = NULL;
+
+		if (fol && TNY_IS_FOLDER (fol)) {
 			mid = tny_folder_get_id (TNY_FOLDER (fol));
-		if (parent_store && TNY_IS_FOLDER (parent_store))
+			maccount = tny_folder_get_account (TNY_FOLDER (fol));
+			if (maccount) {
+				ma_id = tny_account_get_id (maccount);
+				g_object_unref (maccount);
+			}
+		}
+		if (parent_store && TNY_IS_FOLDER (parent_store)) {
 			sid = tny_folder_get_id (TNY_FOLDER (parent_store));
-		if (sid && mid && !strcmp (sid, mid))
-			found = TRUE;
+			saccount = tny_folder_get_account (TNY_FOLDER (parent_store));
+			if (saccount) {
+				sa_id = tny_account_get_id (saccount);
+				g_object_unref (saccount);
+			}
+		}
+		if (sid && mid && !strcmp (sid, mid)) {
+			if (ma_id && sa_id) {
+				if (!strcmp (ma_id, sa_id))
+					found = TRUE;
+			} else {
+				found = TRUE;
+			}
+		}
 	}
 
 	if (found) 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]