Welcome, Guest. Please login or register.

Author Topic: MUI 3.8 - DisplayHook for Listviews.  (Read 116 times)

Description:

0 Members and 2 Guests are viewing this topic.

Offline DocsterTopic starter

  • Newbie
  • *
  • Join Date: Apr 2026
  • Posts: 2
  • Country: no
  • Gender: Male
    • Show only replies by Docster
MUI 3.8 - DisplayHook for Listviews.
« on: April 12, 2026, 06:41:44 AM »
Hey all,

I have a small problem with my program. My program uses listview columns, and it works well. Well, until I get further down the list one listitem seems to be garbage. Then the list works again. Then another one is garbage.

Here is my DisplayHook function:

void FileListDisplay(struct Hook *hook, char **array, struct FileAreaEntry *e)
{
   if (e)
   {
      *array++ = e->Filename;
      *array++ = e->Deleted;
   }
   else
   {
      *array++ = GetString(MSG_FILENAME_HEADER);
      *array++ = (PrefsConfig->FE_ShowKB==0 ? GetString(MSG_FILESIZE_HEADER) : GetString(MSG_FILESIZEKB_HEADER)); //newFileSize;
   }
}

The FileAreaEntry struct like this:

struct FileAreaEntry
{
   STRPTR Deleted;
   STRPTR Filename;
};

The filelist object:

    ObjectApp->filelist = ListObject,
        MUIA_Frame, MUIV_Frame_InputList,
        MUIA_List_Format, "P=\33l BAR,P=\33r",
        MUIA_List_Title,TRUE,
        MUIA_List_Active, MUIV_List_Active_Top,
        MUIA_List_ConstructHook, MUIV_List_ConstructHook_String,
        MUIA_List_DestructHook, MUIV_List_DestructHook_String,
        MUIA_List_DisplayHook, &FileListDisplayHook,
    End;

Also; the filelist is an mem allocation:

#define MAXFILES 4000

struct MyFileList
{
   NameT FileSize;
   NameT FileName;
};

#define SIZEOFFILEINFO sizeof(struct MyFileList)

static struct FileAreaEntry fa;

struct MyFileList *myFileList;
   myFileList = malloc((32*MAXFILES)+SIZEOFFILEINFO*MAXFILES);

The InsertFile function:
void InsertFile(char *fdel,char *fname)
{
   fa.Filename = fname;
   fa.Deleted  = fdel;

   DoMethod(App->filelist,
          MUIM_List_InsertSingle,
          &fa,
          MUIV_List_Insert_Bottom);
}

Please help, I can't seem to get this fixed. The garbage is always in column 0 (Filename). Like the pointer is not working on this specific list item. Is my FileListDisplay wrong?

I have included a screenshot showing this.

Thanks in advance,
Docster
 

Offline futaura

Re: MUI 3.8 - DisplayHook for Listviews.
« Reply #1 on: April 12, 2026, 03:56:32 PM »
You're using MUIV_List_ConstructHook_String and MUIV_List_DestructHook_String, but you are not inserting a single string, you're passing a structure.

So, you need to add proper construct hook which will read your "struct FileAreaEntry", allocate a new "struct FileAreaEntry" and space to hold the string, then copy the strings. Ensure you free everything in the destruct hook.
 

Offline DocsterTopic starter

  • Newbie
  • *
  • Join Date: Apr 2026
  • Posts: 2
  • Country: no
  • Gender: Male
    • Show only replies by Docster
Re: MUI 3.8 - DisplayHook for Listviews.
« Reply #2 on: April 12, 2026, 08:53:54 PM »
Do you have an example how do set these up ? I'm using columns, thats why I'm sending an object to the DisplayHook.

Thanks for reply! :)

Best regards,
Docster