diff options
-rw-r--r-- | divelist-gtk.c | 11 | ||||
-rw-r--r-- | divelist.c | 3 | ||||
-rw-r--r-- | gtk-gui.c | 14 | ||||
-rw-r--r-- | info.c | 7 |
4 files changed, 32 insertions, 3 deletions
diff --git a/divelist-gtk.c b/divelist-gtk.c index f5ed73eb6..ad0f5efe8 100644 --- a/divelist-gtk.c +++ b/divelist-gtk.c @@ -1074,9 +1074,6 @@ static void invalid_dives_cb(GtkWidget *menuitem, GtkTreePath *path) return; /* walk the dive list in chronological order */ for_each_dive(i, dive) { - dive = get_dive(i); - if (!dive) - continue; if (!dive->selected) continue; /* now swap the invalid tag if just 1 dive was selected @@ -1093,7 +1090,15 @@ static void invalid_dives_cb(GtkWidget *menuitem, GtkTreePath *path) changed = 1; } } + /* if invalid dives aren't shown they need to be + * de-selected here to avoid confusion */ + if (dive->selected && !prefs.display_invalid_dives) { + dive->selected = 0; + amount_selected--; + } } + if (amount_selected == 0) + selected_dive = -1; if (changed) { dive_list_update_dives(); mark_divelist_changed(TRUE); diff --git a/divelist.c b/divelist.c index 13ed5113f..d105da52e 100644 --- a/divelist.c +++ b/divelist.c @@ -852,6 +852,9 @@ void select_dive(int idx) { struct dive *dive = get_dive(idx); if (dive && !dive->selected) { + /* never select an invalid dive that isn't displayed */ + if (dive->dive_tags & DTAG_INVALID && !prefs.display_invalid_dives) + return; dive->selected = 1; amount_selected++; selected_dive = idx; @@ -1027,9 +1027,23 @@ static void preferences_dialog(GtkWidget *w, gpointer data) result = gtk_dialog_run(GTK_DIALOG(dialog)); if (result == GTK_RESPONSE_ACCEPT) { const char *po2_threshold_text, *pn2_threshold_text, *phe_threshold_text, *mod_text, *gflow_text, *gfhigh_text; + int j; + struct dive *d; + /* Make sure to flush any modified old dive data with old units */ update_dive(NULL); + /* if we turned off displaying invalid dives. de-select all + * invalid dives that were selected before hiding them */ + if (oldprefs.display_invalid_dives && !prefs.display_invalid_dives) { + for_each_dive(j, d) + if (d->selected && d->dive_tags && DTAG_INVALID) { + d->selected = 0; + amount_selected--; + } + if (amount_selected == 0) + selected_dive = -1; + } prefs.divelist_font = strdup(gtk_font_button_get_font_name(GTK_FONT_BUTTON(font))); set_divelist_font(prefs.divelist_font); po2_threshold_text = gtk_entry_get_text(GTK_ENTRY(entry_po2)); @@ -609,6 +609,13 @@ static void save_dive_info_changes(struct dive *dive, struct dive *master, struc if (tags_shown && dive->dive_tags != master->dive_tags) { changed = 1; dive->dive_tags = master->dive_tags; + /* if a dive is selected and we aren't showing invalid dives and it is + * now marked as invalid we need to deselect it to keep the selection + * state consistent */ + if (!prefs.display_invalid_dives && dive->selected && dive->dive_tags & DTAG_INVALID) { + dive->selected = 0; + amount_selected--; + } } if (changed) { mark_divelist_changed(TRUE); |