--- trunk/src/main.c 2009/08/24 09:23:36 74 +++ trunk/src/main.c 2009/09/11 12:16:50 107 @@ -138,40 +138,50 @@ gtk_widget_show_all (GTK_WIDGET(dialog)); if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) { char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); - - gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); - - if(!whole_dir) - gpx = gpx_parse(dialog, filename); - else { - /* cur trailing '/' if present */ - if(strlastchr(filename) == '/') - filename[strlen(filename)] = 0; - - gpx = gpx_parse_dir(dialog, filename); - } - - gpx_busy_dialog_destroy(dialog); - - /* save path if gpx was successfully loaded */ - if(gpx) { - char *r = strrchr(filename, '/'); - - /* there is a delimiter, use everything left of it as path */ - if(r && !whole_dir) { - *r = 0; - if(appdata->path) free(appdata->path); - appdata->path = strdup(filename); - /* restore path ... just in case ... */ - *r = '/'; + + if(filename) { + gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); + + if(!whole_dir) + gpx = gpx_parse(dialog, filename); + else { + /* cur trailing '/' if present */ + if(strlastchr(filename) == '/') + filename[strlen(filename)] = 0; + + gpx = gpx_parse_dir(dialog, filename); } - - if(whole_dir) - appdata->path = strdup(filename); - } else - errorf(_("Load error")); - - g_free (filename); + + gpx_busy_dialog_destroy(dialog); + + /* save path if gpx was successfully loaded */ + if(gpx) { + char *r = strrchr(filename, '/'); + + /* there is a delimiter, use everything left of it as path */ + if(r && !whole_dir) { + *r = 0; + if(appdata->path) free(appdata->path); + appdata->path = strdup(filename); + /* restore path ... just in case ... */ + *r = '/'; + } + + if(whole_dir) + appdata->path = strdup(filename); + } else + errorf(_("Load error")); + + g_free (filename); + } else { +#ifndef USE_MAEMO + errorf(_("Error accessing the file.")); +#else + errorf(_("Error accessing the file. This may happen if the file " + "resides on a remote file system. Please copy the file onto " + "the device (e.g. onto the memory card) and try again.")); +#endif + } } gtk_widget_destroy (dialog);