@@ -158,7 +158,7 @@ bool MCImageDecode(IO_handle p_stream, MCImageFrame *&r_frames, uindex_t &r_fram
158158 MCImageCompressedBitmap *t_compressed = nil;
159159
160160 MCPoint t_hotspot;
161- char * t_name = nil;
161+ MCStringRef t_name = nil;
162162
163163 if (t_success)
164164 t_success = MCImageImport (p_stream, nil, t_hotspot, t_name, t_compressed, t_bitmap);
@@ -181,7 +181,7 @@ bool MCImageDecode(IO_handle p_stream, MCImageFrame *&r_frames, uindex_t &r_fram
181181
182182 MCImageFreeCompressedBitmap (t_compressed);
183183 MCImageFreeBitmap (t_bitmap);
184- MCCStringFree (t_name);
184+ MCValueRelease (t_name);
185185
186186 return t_success;
187187}
@@ -206,7 +206,7 @@ bool MCImageDecode(const uint8_t *p_data, uindex_t p_size, MCImageFrame *&r_fram
206206}
207207
208208// if the image is in a directly supported format return the raw data otherwise decode & return the bitmap
209- bool MCImageImport (IO_handle p_stream, IO_handle p_mask_stream, MCPoint &r_hotspot, char * &r_name, MCImageCompressedBitmap *&r_compressed, MCImageBitmap *&r_bitmap)
209+ bool MCImageImport (IO_handle p_stream, IO_handle p_mask_stream, MCPoint &r_hotspot, MCStringRef &r_name, MCImageCompressedBitmap *&r_compressed, MCImageBitmap *&r_bitmap)
210210{
211211 bool t_success = true ;
212212
@@ -273,9 +273,7 @@ bool MCImageImport(IO_handle p_stream, IO_handle p_mask_stream, MCPoint &r_hotsp
273273 t_success = MCImageDecodeXWD (p_stream, &t_name, t_bitmap);
274274 if (t_success)
275275 {
276- char *temp;
277- /* UNCHECKED */ MCStringConvertToCString (*t_name, temp);
278- r_name = temp;
276+ r_name = MCValueRetain (*t_name);
279277 }
280278
281279 }
@@ -296,7 +294,7 @@ IO_stat MCImage::import(const char *newname, IO_handle stream, IO_handle mstream
296294
297295 MCImageCompressedBitmap *t_compressed = nil;
298296 MCImageBitmap *t_bitmap = nil;
299- char * t_name = nil;
297+ MCStringRef t_name = nil;
300298 MCPoint t_hotspot = {1 , 1 };
301299
302300 t_success = MCImageImport (stream, mstream, t_hotspot, t_name, t_compressed, t_bitmap);
@@ -338,7 +336,11 @@ IO_stat MCImage::import(const char *newname, IO_handle stream, IO_handle mstream
338336 }
339337
340338 if (isunnamed () && t_name != nil)
341- setname_cstring (t_name);
339+ {
340+ MCNewAutoNameRef t_name_nameref;
341+ /* UNCHECKED */ MCNameCreate (t_name, &t_name_nameref);
342+ setname (*t_name_nameref);
343+ }
342344 if (isunnamed () && newname != nil)
343345 {
344346 const char *tname = strrchr (newname, PATH_SEPARATOR);
@@ -351,7 +353,7 @@ IO_stat MCImage::import(const char *newname, IO_handle stream, IO_handle mstream
351353
352354 }
353355
354- MCCStringFree (t_name);
356+ MCValueRelease (t_name);
355357
356358 return t_success ? IO_NORMAL : IO_ERROR;
357359}
0 commit comments