diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-05-21 23:13:45 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-05-21 23:39:49 -0700 |
commit | 478baf107623c3aa0c31c3256cfc3bc794b089b1 (patch) | |
tree | 090485f799a36090bf4a301ba8611f0b5686a44a /file.c | |
parent | 5aa8b52f82399bd4343a8213927c7e9694def1bc (diff) | |
download | subsurface-478baf107623c3aa0c31c3256cfc3bc794b089b1.tar.gz |
Replace GError handling with a kMessageWidget based approach
Instead of passing pointers to GError around we pass just pointers to
error message texts around and use kMessageWidget to show those. Problem
is that right now the close button on that doesn't do a thing - so the
error stays around indefinitely. Oops.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 19 |
1 files changed, 8 insertions, 11 deletions
@@ -61,7 +61,7 @@ out: } -static void zip_read(struct zip_file *file, GError **error, const char *filename) +static void zip_read(struct zip_file *file, char **error, const char *filename) { int size = 1024, n, read = 0; char *mem = malloc(size); @@ -76,7 +76,7 @@ static void zip_read(struct zip_file *file, GError **error, const char *filename free(mem); } -static int try_to_open_zip(const char *filename, struct memblock *mem, GError **error) +static int try_to_open_zip(const char *filename, struct memblock *mem, char **error) { int success = 0; /* Grr. libzip needs to re-open the file, it can't take a buffer */ @@ -97,7 +97,7 @@ static int try_to_open_zip(const char *filename, struct memblock *mem, GError ** return success; } -static int try_to_open_db(const char *filename, struct memblock *mem, GError **error) +static int try_to_open_db(const char *filename, struct memblock *mem, char **error) { return parse_dm4_buffer(filename, mem->buffer, mem->size, &dive_table, error); } @@ -223,7 +223,7 @@ static int try_to_open_csv(const char *filename, struct memblock *mem, enum csv_ return 1; } -static int open_by_filename(const char *filename, const char *fmt, struct memblock *mem, GError **error) +static int open_by_filename(const char *filename, const char *fmt, struct memblock *mem, char **error) { /* Suunto Dive Manager files: SDE */ if (!strcasecmp(fmt, "SDE")) @@ -250,7 +250,7 @@ static int open_by_filename(const char *filename, const char *fmt, struct memblo return 0; } -static void parse_file_buffer(const char *filename, struct memblock *mem, GError **error) +static void parse_file_buffer(const char *filename, struct memblock *mem, char **error) { char *fmt = strrchr(filename, '.'); if (fmt && open_by_filename(filename, fmt+1, mem, error)) @@ -259,7 +259,7 @@ static void parse_file_buffer(const char *filename, struct memblock *mem, GError parse_xml_buffer(filename, mem->buffer, mem->size, &dive_table, error); } -void parse_file(const char *filename, GError **error) +void parse_file(const char *filename, char **error) { struct memblock mem; char *fmt; @@ -269,12 +269,9 @@ void parse_file(const char *filename, GError **error) if (prefs.default_filename && ! strcmp(filename, prefs.default_filename)) return; - g_warning(_("Failed to read '%s'.\n"), filename); if (error) { - *error = g_error_new(g_quark_from_string("subsurface"), - DIVE_ERROR_PARSE, - _("Failed to read '%s'"), - filename); + *error = malloc(1024); + snprintf(*error, 1024, _("Failed to read '%s'"), filename); } return; |