From ec4e644e76843ca7694ac9593e577766d14d4dd6 Mon Sep 17 00:00:00 2001 From: Cristy Date: Mon, 24 Jun 2019 10:58:25 -0400 Subject: [PATCH] Clone rather than copy window title --- MagickCore/animate.c | 39 +++++++++++++++++++++++++-------------- MagickCore/display.c | 17 +++++++++-------- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/MagickCore/animate.c b/MagickCore/animate.c index 48cf8fd3d..a32fcdfa4 100644 --- a/MagickCore/animate.c +++ b/MagickCore/animate.c @@ -480,7 +480,8 @@ static Image *XMagickCommand(Display *display,XResourceInfo *resource_info, case PlayCommand: { char - basename[MagickPathExtent]; + basename[MagickPathExtent], + name[MagickPathExtent]; int status; @@ -491,8 +492,9 @@ static Image *XMagickCommand(Display *display,XResourceInfo *resource_info, *state|=PlayAnimationState; *state&=(~AutoReverseAnimationState); GetPathComponent((*image)->magick_filename,BasePath,basename); - (void) FormatLocaleString(windows->image.name,MagickPathExtent, - "%s: %s",MagickPackageName,basename); + (void) FormatLocaleString(name,MagickPathExtent,"%s: %s", + MagickPackageName,basename); + (void) CloneString(&windows->image.name,name); if (resource_info->title != (char *) NULL) { char @@ -500,7 +502,7 @@ static Image *XMagickCommand(Display *display,XResourceInfo *resource_info, title=InterpretImageProperties(resource_info->image_info,*image, resource_info->title,exception); - (void) CopyMagickString(windows->image.name,title,MagickPathExtent); + (void) CloneString(&windows->image.name,title); title=DestroyString(title); } status=XStringListToTextProperty(&windows->image.name,1,&window_name); @@ -1664,23 +1666,25 @@ MagickExport Image *XAnimateImages(Display *display, title=InterpretImageProperties(resource_info->image_info,display_image, resource_info->title,exception); - (void) CopyMagickString(windows->image.name,title,MagickPathExtent); - (void) CopyMagickString(windows->image.icon_name,title,MagickPathExtent); + (void) CloneString(&windows->image.name,title); + (void) CloneString(&windows->image.icon_name,title); title=DestroyString(title); } else { char - filename[MagickPathExtent]; + filename[MagickPathExtent], + window_name[MagickPathExtent]; /* Window name is the base of the filename. */ GetPathComponent(display_image->magick_filename,TailPath,filename); - (void) FormatLocaleString(windows->image.name,MagickPathExtent, + (void) FormatLocaleString(window_name,MagickPathExtent, "%s: %s[scene: %.20g frames: %.20g]",MagickPackageName,filename,(double) display_image->scene,(double) number_scenes); - (void) CopyMagickString(windows->image.icon_name,filename,MagickPathExtent); + (void) CloneString(&windows->image.name,window_name); + (void) CloneString(&windows->image.icon_name,filename); } if (resource_info->immutable != MagickFalse) windows->image.immutable=MagickTrue; @@ -1974,18 +1978,22 @@ MagickExport Image *XAnimateImages(Display *display, title=InterpretImageProperties(resource_info->image_info, image_list[scene],resource_info->title,exception); - (void) CopyMagickString(windows->image.name,title,MagickPathExtent); + (void) CloneString(&windows->image.name,title); title=DestroyString(title); } else { + char + window_name[MaxTextExtent]; + p=image_list[scene]->magick_filename+ strlen(image_list[scene]->magick_filename)-1; while ((p > image_list[scene]->magick_filename) && (*(p-1) != '/')) p--; - (void) FormatLocaleString(windows->image.name,MagickPathExtent, + (void) FormatLocaleString(window_name,MagickPathExtent, "%s: %s[%.20g of %.20g]",MagickPackageName,p,(double) scene+1, (double) number_scenes); + (void) CloneString(&windows->image.name,window_name); } status=XStringListToTextProperty(&windows->image.name,1,&window_name); if (status != Success) @@ -2095,6 +2103,9 @@ MagickExport Image *XAnimateImages(Display *display, if ((state & StepAnimationState) || (resource_info->title != (char *) NULL)) { + char + name[MaxTextExtent]; + /* Update window title. */ @@ -2102,9 +2113,10 @@ MagickExport Image *XAnimateImages(Display *display, strlen(image_list[scene]->filename)-1; while ((p > image_list[scene]->filename) && (*(p-1) != '/')) p--; - (void) FormatLocaleString(windows->image.name,MagickPathExtent, + (void) FormatLocaleString(name,MagickPathExtent, "%s: %s[%.20g of %.20g]",MagickPackageName,p,(double) scene+1,(double) number_scenes); + (void) CloneString(&windows->image.name,name); if (resource_info->title != (char *) NULL) { char @@ -2112,8 +2124,7 @@ MagickExport Image *XAnimateImages(Display *display, title=InterpretImageProperties(resource_info->image_info, image,resource_info->title,exception); - (void) CopyMagickString(windows->image.name,title, - MagickPathExtent); + (void) CloneString(&windows->image.name,title); title=DestroyString(title); } status=XStringListToTextProperty(&windows->image.name,1, diff --git a/MagickCore/display.c b/MagickCore/display.c index 932309745..d60fa943c 100644 --- a/MagickCore/display.c +++ b/MagickCore/display.c @@ -14724,29 +14724,30 @@ MagickExport Image *XDisplayImage(Display *display,XResourceInfo *resource_info, title=InterpretImageProperties(resource_info->image_info,display_image, resource_info->title,exception); - (void) CopyMagickString(windows->image.name,title,MagickPathExtent); - (void) CopyMagickString(windows->image.icon_name,title,MagickPathExtent); + (void) CloneString(&windows->image.name,title); + (void) CloneString(&windows->image.icon_name,title); title=DestroyString(title); } else { char - filename[MagickPathExtent]; + filename[MagickPathExtent], + window_name[MagickPathExtent]; /* Window name is the base of the filename. */ GetPathComponent(display_image->magick_filename,TailPath,filename); if (display_image->scene == 0) - (void) FormatLocaleString(windows->image.name,MagickPathExtent, - "%s: %s",MagickPackageName,filename); + (void) FormatLocaleString(window_name,MagickPathExtent,"%s: %s", + MagickPackageName,filename); else - (void) FormatLocaleString(windows->image.name,MagickPathExtent, + (void) FormatLocaleString(window_name,MagickPathExtent, "%s: %s[scene: %.20g frames: %.20g]",MagickPackageName,filename, (double) display_image->scene,(double) GetImageListLength( display_image)); - (void) CopyMagickString(windows->image.icon_name,filename, - MagickPathExtent); + (void) CloneString(&windows->image.name,window_name); + (void) CloneString(&windows->image.icon_name,filename); } if (resource_info->immutable) windows->image.immutable=MagickTrue; -- 2.40.0