diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-08-21 15:37:38 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-08-21 15:37:38 -0700 |
commit | e46688d694d33f445ecb2368541898613af0f3b3 (patch) | |
tree | e82c2264d250d0a9a8ca5213a157d50cdfb9f5f1 | |
parent | 0c49d406e0a7dd1fc66da81ece40405fd053302c (diff) | |
download | subsurface-e46688d694d33f445ecb2368541898613af0f3b3.tar.gz |
Fix single-dive editing oddity
The multi-dive case does fine, but the single-dive case (used when
adding a dive, for example) was somewhat confused between the dive index
(which is the location in the dive array) and the dive number.
Fix this by just passing the dive pointer instead (where NULL means to
use the current dive selection).
Reported-by: Jacco van Koll <jacco.van.koll@gmail.com>
Root-caused-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | dive.h | 2 | ||||
-rw-r--r-- | divelist.c | 2 | ||||
-rw-r--r-- | info.c | 15 |
3 files changed, 8 insertions, 11 deletions
@@ -355,7 +355,7 @@ extern void evn_foreach(void (*callback)(const char *, int *, void *), void *dat extern int add_new_dive(struct dive *dive); extern int edit_dive_info(struct dive *dive); -extern int edit_multi_dive_info(int idx); +extern int edit_multi_dive_info(struct dive *single_dive); extern void dive_list_update_dives(void); extern void flush_divelist(struct dive *dive); diff --git a/divelist.c b/divelist.c index ef34b065c..3fd53ffa5 100644 --- a/divelist.c +++ b/divelist.c @@ -1108,7 +1108,7 @@ void add_dive_cb(GtkWidget *menuitem, gpointer data) void edit_dive_cb(GtkWidget *menuitem, gpointer data) { - edit_multi_dive_info(-1); + edit_multi_dive_info(NULL); } static void expand_all_cb(GtkWidget *menuitem, GtkTreeView *tree_view) @@ -166,7 +166,7 @@ static int delete_dive_info(struct dive *dive) static void info_menu_edit_cb(GtkMenuItem *menuitem, gpointer user_data) { - edit_multi_dive_info(-1); + edit_multi_dive_info(NULL); } static void info_menu_delete_cb(GtkMenuItem *menuitem, gpointer user_data) @@ -490,7 +490,7 @@ void update_equipment_data(struct dive *dive, struct dive *master) } /* A negative index means "all selected" */ -int edit_multi_dive_info(int index) +int edit_multi_dive_info(struct dive *single_dive) { int success; GtkWidget *dialog, *vbox; @@ -505,17 +505,17 @@ int edit_multi_dive_info(int index) NULL); vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); - master = get_dive(index); + master = single_dive; if (!master) master = current_dive; - dive_info_widget(vbox, master, &info, index < 0); + dive_info_widget(vbox, master, &info, !single_dive); show_dive_equipment(master, W_IDX_SECONDARY); save_equipment_data(master); gtk_widget_show_all(dialog); success = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT; if (success) { /* Update the non-current selected dives first */ - if (index < 0) { + if (!single_dive) { int i; struct dive *dive; @@ -544,12 +544,9 @@ int edit_multi_dive_info(int index) int edit_dive_info(struct dive *dive) { - int idx; - if (!dive) return 0; - idx = dive->number; - return edit_multi_dive_info(idx); + return edit_multi_dive_info(dive); } static GtkWidget *frame_box(GtkWidget *vbox, const char *fmt, ...) |