diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-09-20 13:12:37 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-09-20 13:15:03 -0700 |
commit | c9bb617a85cd4a340f7d07eea78af5e12d7a8a9b (patch) | |
tree | 6656f65c5aa9532cc81df2d0c4a3bf8e2f2b27ba | |
parent | 4b42c543570563a1ff464ddcb04b5e5171fe1774 (diff) | |
parent | 2f7fa769d4bb3de7c84d621aaab761a4c69394a0 (diff) | |
download | subsurface-c9bb617a85cd4a340f7d07eea78af5e12d7a8a9b.tar.gz |
Merge remote-tracking branch 'origin/single-threaded-gui'
This brings in the last of the outstanding changes that fix bugs that were
discovered when hunting down the long standing crash with some 64bit OSs.
-rw-r--r-- | libdivecomputer.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/libdivecomputer.c b/libdivecomputer.c index d96d2769f..c9683fbb9 100644 --- a/libdivecomputer.c +++ b/libdivecomputer.c @@ -18,6 +18,9 @@ #define NOT_FROG #endif +static const char *progress_bar_text = ""; +static double progress_bar_fraction = 0.0; + static GError *error(const char *fmt, ...) { va_list args; @@ -159,13 +162,13 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata) static void dev_info(device_data_t *devdata, const char *fmt, ...) { - char buffer[32]; + static char buffer[32]; va_list ap; va_start(ap, fmt); vsnprintf(buffer, sizeof(buffer), fmt, ap); va_end(ap); - update_progressbar_text(&devdata->progress, buffer); + progress_bar_text = buffer; } static int import_dive_number = 0; @@ -318,8 +321,9 @@ static void event_cb(dc_device_t *device, dc_event_type_t event, const void *dat dev_info(devdata, "Event: waiting for user action"); break; case DC_EVENT_PROGRESS: - update_progressbar(&devdata->progress, - (double) progress->current / (double) progress->maximum); + if (!progress->maximum) + break; + progress_bar_fraction = (double) progress->current / (double) progress->maximum; break; case DC_EVENT_DEVINFO: dev_info(devdata, "model=%u (0x%08x), firmware=%u (0x%08x), serial=%u (0x%08x)", @@ -406,9 +410,13 @@ GError *do_import(device_data_t *data) /* I'm sure there is some better interface for waiting on a thread in a UI main loop */ import_thread_done = 0; + progress_bar_text = ""; + progress_bar_fraction = 0.0; pthread_create(&pthread, NULL, pthread_wrapper, data); while (!import_thread_done) { import_thread_cancelled = process_ui_events(); + update_progressbar(&data->progress, progress_bar_fraction); + update_progressbar_text(&data->progress, progress_bar_text); usleep(100000); } if (pthread_join(pthread, &retval) < 0) |