Skip to content

Commit 4cfe034

Browse files
author
deadwood
committed
Backport: Extend CreateImage hack
It now support case where address differ in number of digits and falls back to not displaying any images instead of displaying broken text when the hack fails
1 parent 063235f commit 4cfe034

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

workbench/classes/zune/listtree/listtree.c

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,24 +116,39 @@ static IPTR DisplayHook_Proxy(struct Hook *hook, Object *obj, struct MUIP_NListt
116116
/* Unholy Hack: see comment in in MUIM_List_CreateImage
117117
* Modify the pointer value given by user in display hook. User was thinking he was given
118118
* correct structure by MUIM_List_CreateImage, but that is not true for internal NListtree.
119-
* Modify the address that will be used by NListtree. This works only because the msg->Array
119+
* Modify the address so it can be used by NListtree. This works only because the msg->Array
120120
* buffer in case of O[] has to be dinamically allocated and writable (so that user can put
121121
* address there)
122122
*/
123123
if ((s = strstr(column, "O[")) != NULL)
124124
{
125-
char tmp[16];
125+
char tmp[16], *e;
126+
int len_o, len_h;
127+
126128
s += 2;
127-
char *e = strchr(s, ']');
128-
int len = e - s;
129-
struct ListImage *li = (struct ListImage *)strtoul(s, NULL, 16);
130-
APTR nlistimg = li->nlistimg;
131-
sprintf(tmp, "%lx", nlistimg);
132-
int len2 = strlen(tmp);
133-
memcpy(s, tmp, len);
129+
e = strchr(s, ']');
130+
len_o = e - s;
134131

135-
if (len != len2)
132+
struct ListImage *li = (struct ListImage *)strtoul(s, NULL, 16);
133+
sprintf(tmp, "%lx", li->nlistimg);
134+
len_h = strlen(tmp);
135+
136+
if (len_o == len_h)
137+
memcpy(s, tmp, len_h);
138+
else if (len_o == len_h + 1)
139+
{
140+
memcpy(s, tmp, len_h);
141+
s[len_h] = ']'; s[len_h + 1] = ' ';
142+
}
143+
else
144+
{
136145
bug("[Listtree] CreateImage workaround BROKEN, see comment in code!\n");
146+
/* Doing nothing will lead to NList using original address as BitMapImage. It will
147+
* then check BitMapImage->control (first ULONG) and will find it 0(NULL) so neither
148+
* MUIA_Image_Spec nor MUIM_NList_CreateImage in which case it will just ingore
149+
* the object and not render anything.
150+
*/
151+
}
137152
}
138153
}
139154

workbench/classes/zune/listtree/listtree.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
##begin config
22
basename Listtree
3-
version 0.10
4-
date 30.12.2023
3+
version 0.11
4+
date 30.1.2024
55
superclass MUIC_List
66
classdatatype struct Listtree_DATA
77
##end config

0 commit comments

Comments
 (0)