Return when brush loading failed and react the right way. Fixes parts of

Return when brush loading failed and react the right way. Fixes
 parts of bug #8150.
This commit is contained in:
Daniel Egger 2000-09-27 17:50:59 +00:00
parent 9d051ffcde
commit 4b2c4d8424
10 changed files with 53 additions and 28 deletions

View File

@ -1,4 +1,14 @@
Wed Sep 27 00:46:31 CEST 2000 Daniel Egger <egger@suse.de> Wed Sep 27 19:43:05 CEST 2000 Daniel Egger <egger@suse.de>
* gimpbrush.c:
* gimpbrush.h:
* gimpbrushgenerated.c: Return failed brush load try
in gimp_brush_load_brush and react accordingly instead
of crashing. Fixes part of bug #8150. I'd really
appreciate if some expert could have a look in the
pixmapbrush and brushpipe half of this problem.
Wed Sep 27 19:43:13 CEST 2000 Daniel Egger <egger@suse.de>
* app/paint_funcs.c: Implemented suggested solution for * app/paint_funcs.c: Implemented suggested solution for
SPARC alignment problem by Jon Hazen. Fixes bug #21269. SPARC alignment problem by Jon Hazen. Fixes bug #21269.

View File

@ -126,9 +126,7 @@ gimp_brush_new (gchar *filename)
{ {
GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ())); GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
gimp_brush_load (brush, filename); return (gimp_brush_load (brush, filename)? brush : NULL);
return brush;
} }
static GimpBrush * static GimpBrush *
@ -193,7 +191,7 @@ gimp_brush_set_spacing (GimpBrush *brush,
brush->spacing = spacing; brush->spacing = spacing;
} }
void gboolean
gimp_brush_load (GimpBrush *brush, gimp_brush_load (GimpBrush *brush,
gchar *filename) gchar *filename)
{ {
@ -205,10 +203,11 @@ gimp_brush_load (GimpBrush *brush,
if (! (fp = fopen (filename, "rb"))) if (! (fp = fopen (filename, "rb")))
{ {
gimp_object_destroy (brush); gimp_object_destroy (brush);
return; return FALSE;
} }
gimp_brush_load_brush (brush, fp, filename); if (!gimp_brush_load_brush (brush, fp, filename))
return FALSE;
/* Clean up */ /* Clean up */
fclose (fp); fclose (fp);
@ -216,6 +215,8 @@ gimp_brush_load (GimpBrush *brush,
/* Swap the brush to disk (if we're being stingy with memory) */ /* Swap the brush to disk (if we're being stingy with memory) */
if (stingy_memory_use) if (stingy_memory_use)
temp_buf_swap (brush->mask); temp_buf_swap (brush->mask);
return TRUE;
} }
gint gint

View File

@ -126,9 +126,7 @@ gimp_brush_new (gchar *filename)
{ {
GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ())); GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
gimp_brush_load (brush, filename); return (gimp_brush_load (brush, filename)? brush : NULL);
return brush;
} }
static GimpBrush * static GimpBrush *
@ -193,7 +191,7 @@ gimp_brush_set_spacing (GimpBrush *brush,
brush->spacing = spacing; brush->spacing = spacing;
} }
void gboolean
gimp_brush_load (GimpBrush *brush, gimp_brush_load (GimpBrush *brush,
gchar *filename) gchar *filename)
{ {
@ -205,10 +203,11 @@ gimp_brush_load (GimpBrush *brush,
if (! (fp = fopen (filename, "rb"))) if (! (fp = fopen (filename, "rb")))
{ {
gimp_object_destroy (brush); gimp_object_destroy (brush);
return; return FALSE;
} }
gimp_brush_load_brush (brush, fp, filename); if (!gimp_brush_load_brush (brush, fp, filename))
return FALSE;
/* Clean up */ /* Clean up */
fclose (fp); fclose (fp);
@ -216,6 +215,8 @@ gimp_brush_load (GimpBrush *brush,
/* Swap the brush to disk (if we're being stingy with memory) */ /* Swap the brush to disk (if we're being stingy with memory) */
if (stingy_memory_use) if (stingy_memory_use)
temp_buf_swap (brush->mask); temp_buf_swap (brush->mask);
return TRUE;
} }
gint gint

View File

@ -55,7 +55,7 @@ struct _GimpBrushClass
GtkType gimp_brush_get_type (void); GtkType gimp_brush_get_type (void);
GimpBrush * gimp_brush_new (gchar *filename); GimpBrush * gimp_brush_new (gchar *filename);
void gimp_brush_load (GimpBrush *brush, gboolean gimp_brush_load (GimpBrush *brush,
gchar *filename); gchar *filename);
gint gimp_brush_load_brush (GimpBrush *brush, gint gimp_brush_load_brush (GimpBrush *brush,
FILE *fp, FILE *fp,

View File

@ -134,7 +134,10 @@ gimp_brush_generated_load (const gchar *file_name)
/* make sure the file we are reading is the right type */ /* make sure the file we are reading is the right type */
fgets (string, 255, fp); fgets (string, 255, fp);
g_return_val_if_fail (strncmp (string, "GIMP-VBR", 8) == 0, NULL);
if (strncmp (string, "GIMP-VBR", 8) != 0)
return NULL;
/* make sure we are reading a compatible version */ /* make sure we are reading a compatible version */
fgets (string, 255, fp); fgets (string, 255, fp);
sscanf (string, "%f", &version); sscanf (string, "%f", &version);

View File

@ -134,7 +134,10 @@ gimp_brush_generated_load (const gchar *file_name)
/* make sure the file we are reading is the right type */ /* make sure the file we are reading is the right type */
fgets (string, 255, fp); fgets (string, 255, fp);
g_return_val_if_fail (strncmp (string, "GIMP-VBR", 8) == 0, NULL);
if (strncmp (string, "GIMP-VBR", 8) != 0)
return NULL;
/* make sure we are reading a compatible version */ /* make sure we are reading a compatible version */
fgets (string, 255, fp); fgets (string, 255, fp);
sscanf (string, "%f", &version); sscanf (string, "%f", &version);

View File

@ -134,7 +134,10 @@ gimp_brush_generated_load (const gchar *file_name)
/* make sure the file we are reading is the right type */ /* make sure the file we are reading is the right type */
fgets (string, 255, fp); fgets (string, 255, fp);
g_return_val_if_fail (strncmp (string, "GIMP-VBR", 8) == 0, NULL);
if (strncmp (string, "GIMP-VBR", 8) != 0)
return NULL;
/* make sure we are reading a compatible version */ /* make sure we are reading a compatible version */
fgets (string, 255, fp); fgets (string, 255, fp);
sscanf (string, "%f", &version); sscanf (string, "%f", &version);

View File

@ -126,9 +126,7 @@ gimp_brush_new (gchar *filename)
{ {
GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ())); GimpBrush *brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
gimp_brush_load (brush, filename); return (gimp_brush_load (brush, filename)? brush : NULL);
return brush;
} }
static GimpBrush * static GimpBrush *
@ -193,7 +191,7 @@ gimp_brush_set_spacing (GimpBrush *brush,
brush->spacing = spacing; brush->spacing = spacing;
} }
void gboolean
gimp_brush_load (GimpBrush *brush, gimp_brush_load (GimpBrush *brush,
gchar *filename) gchar *filename)
{ {
@ -205,10 +203,11 @@ gimp_brush_load (GimpBrush *brush,
if (! (fp = fopen (filename, "rb"))) if (! (fp = fopen (filename, "rb")))
{ {
gimp_object_destroy (brush); gimp_object_destroy (brush);
return; return FALSE;
} }
gimp_brush_load_brush (brush, fp, filename); if (!gimp_brush_load_brush (brush, fp, filename))
return FALSE;
/* Clean up */ /* Clean up */
fclose (fp); fclose (fp);
@ -216,6 +215,8 @@ gimp_brush_load (GimpBrush *brush,
/* Swap the brush to disk (if we're being stingy with memory) */ /* Swap the brush to disk (if we're being stingy with memory) */
if (stingy_memory_use) if (stingy_memory_use)
temp_buf_swap (brush->mask); temp_buf_swap (brush->mask);
return TRUE;
} }
gint gint

View File

@ -55,7 +55,7 @@ struct _GimpBrushClass
GtkType gimp_brush_get_type (void); GtkType gimp_brush_get_type (void);
GimpBrush * gimp_brush_new (gchar *filename); GimpBrush * gimp_brush_new (gchar *filename);
void gimp_brush_load (GimpBrush *brush, gboolean gimp_brush_load (GimpBrush *brush,
gchar *filename); gchar *filename);
gint gimp_brush_load_brush (GimpBrush *brush, gint gimp_brush_load_brush (GimpBrush *brush,
FILE *fp, FILE *fp,

View File

@ -134,7 +134,10 @@ gimp_brush_generated_load (const gchar *file_name)
/* make sure the file we are reading is the right type */ /* make sure the file we are reading is the right type */
fgets (string, 255, fp); fgets (string, 255, fp);
g_return_val_if_fail (strncmp (string, "GIMP-VBR", 8) == 0, NULL);
if (strncmp (string, "GIMP-VBR", 8) != 0)
return NULL;
/* make sure we are reading a compatible version */ /* make sure we are reading a compatible version */
fgets (string, 255, fp); fgets (string, 255, fp);
sscanf (string, "%f", &version); sscanf (string, "%f", &version);