@@ -116,24 +116,39 @@ static IPTR DisplayHook_Proxy(struct Hook *hook, Object *obj, struct MUIP_NListt
116
116
/* Unholy Hack: see comment in in MUIM_List_CreateImage
117
117
* Modify the pointer value given by user in display hook. User was thinking he was given
118
118
* 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
120
120
* buffer in case of O[] has to be dinamically allocated and writable (so that user can put
121
121
* address there)
122
122
*/
123
123
if ((s = strstr (column , "O[" )) != NULL )
124
124
{
125
- char tmp [16 ];
125
+ char tmp [16 ], * e ;
126
+ int len_o , len_h ;
127
+
126
128
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 ;
134
131
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
+ {
136
145
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
+ }
137
152
}
138
153
}
139
154
0 commit comments