From c6be2404dafcb5032f8e35d31bca570f0ae80ef6 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 22 Aug 2012 00:26:58 +0300 Subject: [PATCH 1/2] Fix an off-by-one error in buffer allocation Signed-off-by: Mikko Rasa --- gtk-gui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk-gui.c b/gtk-gui.c index 306e1a5e7..ac80a47f4 100644 --- a/gtk-gui.c +++ b/gtk-gui.c @@ -223,7 +223,7 @@ static gboolean ask_save_changes() label = gtk_label_new ( "You have unsaved changes\nWould you like to save those before exiting the program?"); } else { - char *label_text = (char*) malloc(sizeof(char) * (92 + strlen(existing_filename))); + char *label_text = (char*) malloc(sizeof(char) * (93 + strlen(existing_filename))); sprintf(label_text, "You have unsaved changes to file: %s \nWould you like to save those before exiting the program?", existing_filename); From df1f506b4e874a9c5afad8d31989a2389bbcdf2d Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 22 Aug 2012 00:35:08 +0300 Subject: [PATCH 2/2] Check if multi-dive editing is actually needed Context menu callbacks always invoke edit_multi_dive_info(-1) instead of edit_dive_info. Since -1 means "all selected", it was impossible to edit dive notes through the context menus. This commit makes the function check if multiple dives are actually selected. Signed-off-by: Mikko Rasa --- info.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/info.c b/info.c index 468f35772..66e4f0adc 100644 --- a/info.c +++ b/info.c @@ -496,6 +496,7 @@ int edit_multi_dive_info(int index) GtkWidget *dialog, *vbox; struct dive_info info; struct dive *master; + gboolean multi; dialog = gtk_dialog_new_with_buttons("Dive Info", GTK_WINDOW(main_window), @@ -508,7 +509,23 @@ int edit_multi_dive_info(int index) master = get_dive(index); if (!master) master = current_dive; - dive_info_widget(vbox, master, &info, index < 0); + + /* See if we should use multi dive mode */ + multi = FALSE; + if (index < 0) + { + int i; + struct dive *dive; + + for (i = 0; (dive = get_dive(i)) != NULL; i++) { + if (dive != master && dive->selected) { + multi = TRUE; + break; + } + } + } + + dive_info_widget(vbox, master, &info, multi); show_dive_equipment(master, W_IDX_SECONDARY); save_equipment_data(master); gtk_widget_show_all(dialog);