From 452b5d587eb17bda68c8fc2e55a6ae8aece3f86b Mon Sep 17 00:00:00 2001 From: mazze Date: Sat, 27 Dec 2008 14:45:41 +0000 Subject: [PATCH] Using MUI_List_Title for Dirlist and Volumelist objects caused segfaults. Now it's checked if entry == NULL. If this happens the hook returns the titles. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@30164 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- workbench/libs/muimaster/classes/dirlist.c | 73 +++++++++++++++------------ workbench/libs/muimaster/classes/volumelist.c | 35 ++++++++----- 2 files changed, 65 insertions(+), 43 deletions(-) diff --git a/workbench/libs/muimaster/classes/dirlist.c b/workbench/libs/muimaster/classes/dirlist.c index 34696b611..b79d7a711 100644 --- a/workbench/libs/muimaster/classes/dirlist.c +++ b/workbench/libs/muimaster/classes/dirlist.c @@ -48,43 +48,54 @@ static LONG display_func(struct Hook *hook, char **array, struct Dirlist_Entry * struct DateTime dt; /* MUI: name | size | Date | Time | Protection | Comment */ - - *array++ = entry->fib.fib_FileName; - - if (entry->fib.fib_DirEntryType > 0) + if (entry) { - *array++ = "\33r\33I[6:22]"; + *array++ = entry->fib.fib_FileName; + + if (entry->fib.fib_DirEntryType > 0) + { + *array++ = "\33r\33I[6:22]"; + } + else + { + snprintf(data->size_string, sizeof(data->size_string), "\33r%ld", entry->fib.fib_Size); + *array++ = data->size_string; + } + + dt.dat_Stamp = entry->fib.fib_Date; + dt.dat_Format = FORMAT_DOS; + dt.dat_Flags = 0; + dt.dat_StrDay = NULL; + dt.dat_StrDate = data->date_string; + dt.dat_StrTime = data->time_string; + + DateToStr(&dt); + + *array++ = data->date_string; + *array++ = data->time_string; + + data->prot_string[0] = (entry->fib.fib_Protection & FIBF_SCRIPT) ? 's' : '-'; + data->prot_string[1] = (entry->fib.fib_Protection & FIBF_PURE) ? 'p' : '-'; + data->prot_string[2] = (entry->fib.fib_Protection & FIBF_ARCHIVE) ? 'a' : '-'; + data->prot_string[3] = (entry->fib.fib_Protection & FIBF_READ) ? '-' : 'r'; + data->prot_string[4] = (entry->fib.fib_Protection & FIBF_WRITE) ? '-' : 'w'; + data->prot_string[5] = (entry->fib.fib_Protection & FIBF_EXECUTE) ? '-' : 'e'; + data->prot_string[6] = (entry->fib.fib_Protection & FIBF_DELETE ) ? '-' : 'd'; + data->prot_string[7] = '\0'; + + *array++ = data->prot_string; + *array = entry->fib.fib_Comment; } else { - snprintf(data->size_string, sizeof(data->size_string), "\33r%ld", entry->fib.fib_Size); - *array++ = data->size_string; + *array++ = "Name"; + *array++ = "Size"; + *array++ = "Date"; + *array++ = "Time"; + *array++ = "Flags"; + *array = "Comment"; } - dt.dat_Stamp = entry->fib.fib_Date; - dt.dat_Format = FORMAT_DOS; - dt.dat_Flags = 0; - dt.dat_StrDay = NULL; - dt.dat_StrDate = data->date_string; - dt.dat_StrTime = data->time_string; - - DateToStr(&dt); - - *array++ = data->date_string; - *array++ = data->time_string; - - data->prot_string[0] = (entry->fib.fib_Protection & FIBF_SCRIPT) ? 's' : '-'; - data->prot_string[1] = (entry->fib.fib_Protection & FIBF_PURE) ? 'p' : '-'; - data->prot_string[2] = (entry->fib.fib_Protection & FIBF_ARCHIVE) ? 'a' : '-'; - data->prot_string[3] = (entry->fib.fib_Protection & FIBF_READ) ? '-' : 'r'; - data->prot_string[4] = (entry->fib.fib_Protection & FIBF_WRITE) ? '-' : 'w'; - data->prot_string[5] = (entry->fib.fib_Protection & FIBF_EXECUTE) ? '-' : 'e'; - data->prot_string[6] = (entry->fib.fib_Protection & FIBF_DELETE ) ? '-' : 'd'; - data->prot_string[7] = '\0'; - - *array++ = data->prot_string; - *array = entry->fib.fib_Comment; - return 0; } diff --git a/workbench/libs/muimaster/classes/volumelist.c b/workbench/libs/muimaster/classes/volumelist.c index 094b5310a..ea0fcecac 100644 --- a/workbench/libs/muimaster/classes/volumelist.c +++ b/workbench/libs/muimaster/classes/volumelist.c @@ -43,24 +43,35 @@ static LONG display_func(struct Hook *hook, char **array, struct Volumelist_Entr { /* MUI: logo | devicename | %-used | bytes free | bytes used */ - if (entry->type == DLT_DEVICE) + if (entry) { - *array++ = "\33I[6:24]"; - } - else if (entry->type == DLT_VOLUME) - { - *array++ = "\33I[6:26]"; + if (entry->type == DLT_DEVICE) + { + *array++ = "\33I[6:24]"; + } + else if (entry->type == DLT_VOLUME) + { + *array++ = "\33I[6:26]"; + } + else + { + *array++ = "\33I[6:29]"; + } + + *array++ = entry->name; + *array++ = ""; + *array++ = ""; + *array = ""; } else { - *array++ = "\33I[6:29]"; + *array++ = "Logo"; + *array++ = "Name"; + *array++ = "% Used"; + *array++ = "Bytes Free"; + *array = "Bytes Used"; } - *array++ = entry->name; - *array++ = ""; - *array++ = ""; - *array = ""; - return 0; } -- 2.11.4.GIT