aboutsummaryrefslogtreecommitdiffstats
path: root/statistics.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-02-18 16:56:28 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-02-18 17:00:18 -0800
commit6ce4d29f4907ec26486d9a16fee29edf1637b543 (patch)
tree494fbc383234f9f92445725f6694863995b19d7c /statistics.c
parentef55ddccb5bff1672e72947500c97fec51963358 (diff)
downloadsubsurface-6ce4d29f4907ec26486d9a16fee29edf1637b543.tar.gz
Clear statistics and equipment when no dive is selected
This all seems very strange forward. The reason for the check whether the stats_w widget has been populated is that at the very beginning, when the UI is still being assembled, a first call to switch_page() happens as the notebook pages are assembled. At that point the stats_w widget is still empty which tells us that we aren't ready to display anything. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'statistics.c')
-rw-r--r--statistics.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/statistics.c b/statistics.c
index fdea8bdba..73c771804 100644
--- a/statistics.c
+++ b/statistics.c
@@ -439,7 +439,7 @@ static void process_all_dives(struct dive *dive, struct dive **prev_dive)
* are in chronological order */
for (idx = 0; idx < dive_table.nr; idx++) {
dp = dive_table.dives[idx];
- if (dp->when == dive->when) {
+ if (dive && dp->when == dive->when) {
/* that's the one we are showing */
if (idx > 0)
*prev_dive = dive_table.dives[idx-1];
@@ -699,7 +699,7 @@ static void get_selected_dives_text(char *buffer, int size)
}
}
-static void show_total_dive_stats(struct dive *dive)
+static void show_total_dive_stats(void)
{
double value;
int decimals, seconds;
@@ -707,6 +707,8 @@ static void show_total_dive_stats(struct dive *dive)
char buffer[60];
stats_t *stats_ptr;
+ if (!stats_w.framelabel)
+ return;
stats_ptr = &stats_selection;
get_selected_dives_text(buffer, sizeof(buffer));
@@ -752,7 +754,7 @@ void show_dive_stats(struct dive *dive)
/* they have to be called in this order, as 'total' depends on
* calculations done in 'single' */
show_single_dive_stats(dive);
- show_total_dive_stats(dive);
+ show_total_dive_stats();
}
static GtkWidget *new_info_label_in_frame(GtkWidget *box, const char *label)