move the mru and docindex calls to before the call to

Mon Aug 24 13:41:49 CDT 1998  Larry Ewing  <lewing@gimp.org>

	* app/fileops.c (file_save): move the mru and docindex calls to
	before the call to gimp_image_set_filename so that they are still
	accessing valid memory.  Fixes the filename corruption seen in
	these interfaces.
	* app/gimpimage.c: added a warning about the side effect that
	caused the above bug.
This commit is contained in:
CDT 1998 Larry Ewing 1998-08-24 18:48:06 +00:00 committed by Larry Ewing
parent 2ada61e007
commit 8474c4e220
10 changed files with 71 additions and 5 deletions

View file

@ -1,3 +1,12 @@
Mon Aug 24 13:41:49 CDT 1998 Larry Ewing <lewing@gimp.org>
* app/fileops.c (file_save): move the mru and docindex calls to
before the call to gimp_image_set_filename so that they are still
accessing valid memory. Fixes the filename corruption seen in
these interfaces.
* app/gimpimage.c: added a warning about the side effect that
caused the above bug.
Mon Aug 24 09:34:37 PDT 1998 Manish Singh <yosh@gimp.org> Mon Aug 24 09:34:37 PDT 1998 Manish Singh <yosh@gimp.org>
* plug-ins/depthmerge.c * plug-ins/depthmerge.c

View file

@ -262,7 +262,14 @@ gimp_image_set_filename (GimpImage *gimage, char *filename)
{ {
char *new_filename; char *new_filename;
/*
* WARNING: this function will free the current filename even if you are
* setting it to itself so any pointer you hold to the filename will be
* invalid after this call. So please use with care.
*/
new_filename = g_strdup (filename); new_filename = g_strdup (filename);
if (gimage->has_filename) if (gimage->has_filename)
g_free (gimage->filename); g_free (gimage->filename);

View file

@ -262,7 +262,14 @@ gimp_image_set_filename (GimpImage *gimage, char *filename)
{ {
char *new_filename; char *new_filename;
/*
* WARNING: this function will free the current filename even if you are
* setting it to itself so any pointer you hold to the filename will be
* invalid after this call. So please use with care.
*/
new_filename = g_strdup (filename); new_filename = g_strdup (filename);
if (gimage->has_filename) if (gimage->has_filename)
g_free (gimage->filename); g_free (gimage->filename);

View file

@ -262,7 +262,14 @@ gimp_image_set_filename (GimpImage *gimage, char *filename)
{ {
char *new_filename; char *new_filename;
/*
* WARNING: this function will free the current filename even if you are
* setting it to itself so any pointer you hold to the filename will be
* invalid after this call. So please use with care.
*/
new_filename = g_strdup (filename); new_filename = g_strdup (filename);
if (gimage->has_filename) if (gimage->has_filename)
g_free (gimage->filename); g_free (gimage->filename);

View file

@ -262,7 +262,14 @@ gimp_image_set_filename (GimpImage *gimage, char *filename)
{ {
char *new_filename; char *new_filename;
/*
* WARNING: this function will free the current filename even if you are
* setting it to itself so any pointer you hold to the filename will be
* invalid after this call. So please use with care.
*/
new_filename = g_strdup (filename); new_filename = g_strdup (filename);
if (gimage->has_filename) if (gimage->has_filename)
g_free (gimage->filename); g_free (gimage->filename);

View file

@ -262,7 +262,14 @@ gimp_image_set_filename (GimpImage *gimage, char *filename)
{ {
char *new_filename; char *new_filename;
/*
* WARNING: this function will free the current filename even if you are
* setting it to itself so any pointer you hold to the filename will be
* invalid after this call. So please use with care.
*/
new_filename = g_strdup (filename); new_filename = g_strdup (filename);
if (gimage->has_filename) if (gimage->has_filename)
g_free (gimage->filename); g_free (gimage->filename);

View file

@ -262,7 +262,14 @@ gimp_image_set_filename (GimpImage *gimage, char *filename)
{ {
char *new_filename; char *new_filename;
/*
* WARNING: this function will free the current filename even if you are
* setting it to itself so any pointer you hold to the filename will be
* invalid after this call. So please use with care.
*/
new_filename = g_strdup (filename); new_filename = g_strdup (filename);
if (gimage->has_filename) if (gimage->has_filename)
g_free (gimage->filename); g_free (gimage->filename);

View file

@ -262,7 +262,14 @@ gimp_image_set_filename (GimpImage *gimage, char *filename)
{ {
char *new_filename; char *new_filename;
/*
* WARNING: this function will free the current filename even if you are
* setting it to itself so any pointer you hold to the filename will be
* invalid after this call. So please use with care.
*/
new_filename = g_strdup (filename); new_filename = g_strdup (filename);
if (gimage->has_filename) if (gimage->has_filename)
g_free (gimage->filename); g_free (gimage->filename);

View file

@ -300,7 +300,7 @@ static GSList *save_procs = NULL;
static PlugInProcDef *load_file_proc = NULL; static PlugInProcDef *load_file_proc = NULL;
static PlugInProcDef *save_file_proc = NULL; static PlugInProcDef *save_file_proc = NULL;
static GimpImage* the_gimage; static GimpImage* the_gimage = NULL;
#define FILE_ERR_MESSAGE(str) G_STMT_START{ \ #define FILE_ERR_MESSAGE(str) G_STMT_START{ \
if (message_handler == MESSAGE_BOX) \ if (message_handler == MESSAGE_BOX) \
@ -813,11 +813,12 @@ file_save (GimpImage* gimage,
/* set this image to clean */ /* set this image to clean */
gimage_clean_all (gimage); gimage_clean_all (gimage);
/* set the image title */ /* these calls must come before the call to gimage_set_filename */
gimage_set_filename (gimage, filename); idea_add (filename);
idea_add( filename );
menus_last_opened_add (filename); menus_last_opened_add (filename);
/* set the image title */
gimp_image_set_filename (gimage, filename);
} }
g_free (return_vals); g_free (return_vals);

View file

@ -262,7 +262,14 @@ gimp_image_set_filename (GimpImage *gimage, char *filename)
{ {
char *new_filename; char *new_filename;
/*
* WARNING: this function will free the current filename even if you are
* setting it to itself so any pointer you hold to the filename will be
* invalid after this call. So please use with care.
*/
new_filename = g_strdup (filename); new_filename = g_strdup (filename);
if (gimage->has_filename) if (gimage->has_filename)
g_free (gimage->filename); g_free (gimage->filename);