From 744323956653d483317aacf56ccb43b92851e395 Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Sun, 13 May 2012 14:55:33 +0000 Subject: [PATCH] Fix issue 477: Crash when browsing drives that have no 'parent directory' entry git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1957 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- src/filesel.c | 11 +++++++++-- src/main.c | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/filesel.c b/src/filesel.c index 7231bf26..ba616572 100644 --- a/src/filesel.c +++ b/src/filesel.c @@ -422,6 +422,13 @@ void Read_list_of_files(T_Fileselector *list, byte selected_format) } } } + if (list->Nb_files==0 && list->Nb_directories==0) + { + // This can happen on some empty network drives. + // Add a dummy entry because the fileselector doesn't + // seem to support empty list. + Add_element_to_list(list, ".",Format_filename(".",19,1),1,ICON_NONE); + } #if defined(__MORPHOS__) || defined(__AROS__) || defined (__amigaos4__) || defined(__amigaos__) Add_element_to_list(list, "/", Format_filename("/",19,1), 1, ICON_NONE); // on amiga systems, / means parent. And there is no .. @@ -436,7 +443,7 @@ void Read_list_of_files(T_Fileselector *list, byte selected_format) for (item = list->First; (((item != NULL) && (bFound==false))); item = item->Next){ if (item->Type == 1){ - if(strncmp(item->Full_name,"..",(sizeof(char)*2))==0) bFound=true; + if(strncmp(item->Full_name,"..",(sizeof(char)*2))==0) bFound=true; } } @@ -1833,7 +1840,7 @@ byte Button_Load_or_Save(byte load, T_IO_Context *context) case SDLK_BACKSPACE : // Backspace Reset_quicksearch(); // Si le choix ".." est bien en tête des propositions... - if (!strcmp(Filelist.First->Full_name,PARENT_DIR)) + if (Filelist.Nb_elements && !strcmp(Filelist.First->Full_name,PARENT_DIR)) { // On va dans le répertoire parent. strcpy(Selector_filename,PARENT_DIR); diff --git a/src/main.c b/src/main.c index ac8ca984..db80991a 100644 --- a/src/main.c +++ b/src/main.c @@ -367,6 +367,7 @@ int Analyze_command_line(int argc, char * argv[], char *main_filename, char *mai } break; default: + printf("[%s]\n", argv[index]); // Si ce n'est pas un paramètre, c'est le nom du fichier à ouvrir if (file_in_command_line > 1) {