From 91124053a7f3ffec90db098858a89071b0f59889 Mon Sep 17 00:00:00 2001 From: akashihi Date: Wed, 16 Jun 2010 21:03:23 +0000 Subject: [PATCH] Fix:core:Bookmarks saving procedure now produces a message in case of failure. This closes ticket#165 git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@3362 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/bookmarks.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/navit/navit/bookmarks.c b/navit/navit/bookmarks.c index 6557143..cf8a113 100644 --- a/navit/navit/bookmarks.c +++ b/navit/navit/bookmarks.c @@ -29,6 +29,7 @@ #include "map.h" #include "command.h" #include "bookmarks.h" +#include "navit_nls.h" struct bookmarks { //data storage @@ -46,7 +47,7 @@ struct bookmarks { struct transformation *trans; struct attr **attrs; struct callback_list *attr_cbl; - struct attr *parent; + struct attr *parent; }; struct bookmark_item_priv { @@ -203,6 +204,10 @@ struct bookmarks * bookmarks_new(struct attr *parent, struct attr **attrs, struct transformation *trans) { struct bookmarks *this_; + if (parent->type!=attr_navit) { + return NULL; + } + this_ = g_new0(struct bookmarks,1); this_->attr_cbl=callback_list_new(); this_->parent=parent; @@ -260,10 +265,12 @@ bookmarks_store_bookmarks_to_file(struct bookmarks *this_, int limit,int replac struct bookmark_item_priv *item,*parent_item; char *fullname; const char *prostr; + int result; GHashTable *dedup=g_hash_table_new_full(g_str_hash,g_str_equal,g_free,NULL); f=fopen(this_->working_file, replace ? "w+" : "a+"); if (f==NULL) { + navit_add_message(this_->parent->u.navit,_("Failed to write bookmarks file")); return FALSE; } @@ -325,7 +332,12 @@ bookmarks_store_bookmarks_to_file(struct bookmarks *this_, int limit,int replac g_hash_table_destroy(dedup); - return rename(this_->working_file,this_->bookmark_file)==0; + result=(rename(this_->working_file,this_->bookmark_file)==0); + if (!result) + { + navit_add_message(this_->parent->u.navit,_("Failed to write bookmarks file")); + } + return result; } /* -- 2.7.4