don't choke on brush files with empty names (bug #343140).

2006-05-29  Sven Neumann  <sven@gimp.org>

	* app/core/gimpbrushgenerated.c (gimp_brush_generated_load): don't
	choke on brush files with empty names (bug #343140).
	(gimp_brush_generated_save): warn about brushes with empty names.
This commit is contained in:
Sven Neumann 2006-05-29 15:43:05 +00:00 committed by Sven Neumann
parent ae0cfe3dc0
commit 6ce6160966
4 changed files with 34 additions and 4 deletions

View file

@ -1,7 +1,13 @@
2006-05-29 Sven Neumann <sven@gimp.org>
* app/core/gimpbrushgenerated.c (gimp_brush_generated_load): don't
choke on brush files with empty names (bug #343140).
(gimp_brush_generated_save): warn about brushes with empty names.
2006-05-29 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpdock.c (gimp_dock_key_press_event): make sure
text widgets get all key events first. Fixes bug #301006.
that text widgets get all key events first. Fixes bug #301006.
2006-05-29 Sven Neumann <sven@gimp.org>

View file

@ -211,10 +211,13 @@ gimp_brush_generated_save (GimpData *data,
GError **error)
{
GimpBrushGenerated *brush = GIMP_BRUSH_GENERATED (data);
const gchar *name = gimp_object_get_name (GIMP_OBJECT (data));
FILE *file;
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
gboolean have_shape = FALSE;
g_return_val_if_fail (name != NULL && *name != '\0', FALSE);
file = g_fopen (data->filename, "wb");
if (! file)
@ -241,7 +244,7 @@ gimp_brush_generated_save (GimpData *data,
}
/* write name */
fprintf (file, "%.255s\n", GIMP_OBJECT (brush)->name);
fprintf (file, "%.255s\n", name);
if (have_shape)
{
@ -602,6 +605,11 @@ gimp_brush_generated_load (const gchar *filename,
goto failed;
g_strstrip (string);
/* the empty string is not an allowed name */
if (strlen (string) < 1)
g_strlcpy (string, _("Untitled"), sizeof (string));
name = gimp_any_to_utf8 (string, -1,
_("Invalid UTF-8 string in brush file '%s'."),
gimp_filename_to_utf8 (filename));

View file

@ -211,10 +211,13 @@ gimp_brush_generated_save (GimpData *data,
GError **error)
{
GimpBrushGenerated *brush = GIMP_BRUSH_GENERATED (data);
const gchar *name = gimp_object_get_name (GIMP_OBJECT (data));
FILE *file;
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
gboolean have_shape = FALSE;
g_return_val_if_fail (name != NULL && *name != '\0', FALSE);
file = g_fopen (data->filename, "wb");
if (! file)
@ -241,7 +244,7 @@ gimp_brush_generated_save (GimpData *data,
}
/* write name */
fprintf (file, "%.255s\n", GIMP_OBJECT (brush)->name);
fprintf (file, "%.255s\n", name);
if (have_shape)
{
@ -602,6 +605,11 @@ gimp_brush_generated_load (const gchar *filename,
goto failed;
g_strstrip (string);
/* the empty string is not an allowed name */
if (strlen (string) < 1)
g_strlcpy (string, _("Untitled"), sizeof (string));
name = gimp_any_to_utf8 (string, -1,
_("Invalid UTF-8 string in brush file '%s'."),
gimp_filename_to_utf8 (filename));

View file

@ -211,10 +211,13 @@ gimp_brush_generated_save (GimpData *data,
GError **error)
{
GimpBrushGenerated *brush = GIMP_BRUSH_GENERATED (data);
const gchar *name = gimp_object_get_name (GIMP_OBJECT (data));
FILE *file;
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
gboolean have_shape = FALSE;
g_return_val_if_fail (name != NULL && *name != '\0', FALSE);
file = g_fopen (data->filename, "wb");
if (! file)
@ -241,7 +244,7 @@ gimp_brush_generated_save (GimpData *data,
}
/* write name */
fprintf (file, "%.255s\n", GIMP_OBJECT (brush)->name);
fprintf (file, "%.255s\n", name);
if (have_shape)
{
@ -602,6 +605,11 @@ gimp_brush_generated_load (const gchar *filename,
goto failed;
g_strstrip (string);
/* the empty string is not an allowed name */
if (strlen (string) < 1)
g_strlcpy (string, _("Untitled"), sizeof (string));
name = gimp_any_to_utf8 (string, -1,
_("Invalid UTF-8 string in brush file '%s'."),
gimp_filename_to_utf8 (filename));