Commit e86a3876 authored by Adam D. Moss's avatar Adam D. Moss
Browse files

Fixed copy-on-write path of copy_region which was sometimes crashing with


	* app/paint_funcs.c:
	Fixed copy-on-write path of copy_region which was sometimes
	crashing with Scott's new tile scheme.

	* app/tile_manager.c:
	Added some sanity warnings.

	* app/xcf.c:
	Fixed copy-on-write tile loading which was causing crashes
	with Scott's new tile scheme.  Ref balance count seems funny
	still.
parent 88618c25
Fri Jul 10 23:06:09 BST 1998 Adam D. Moss <adam@gimp.org>
* app/paint_funcs.c:
Fixed copy-on-write path of copy_region which was sometimes
crashing with Scott's new tile scheme.
* app/tile_manager.c:
Added some sanity warnings.
* app/xcf.c:
Fixed copy-on-write tile loading which was causing crashes
with Scott's new tile scheme. Ref balance count seems funny
still.
1998-07-10 Chris Lahey <clahey@umich.edu>
* app/docindexif.c: New file.
......
......@@ -16,6 +16,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include "tile_cache.h"
#include "tile_manager.h"
#include "tile_swap.h"
......@@ -488,13 +490,22 @@ tile_manager_map_tile (TileManager *tm,
int tile_col;
int tile_num;
/* printf("#");fflush(stdout); */
if ((level < 0) || (level >= tm->nlevels))
return;
{
g_warning ("tile_manager_map_tile: level out of range.");
return;
}
tile_level = &tm->levels[level];
if ((xpixel < 0) || (xpixel >= tile_level->width) ||
(ypixel < 0) || (ypixel >= tile_level->height))
return;
{
g_warning ("tile_manager_map_tile: tile co-ord out of range.");
return;
}
tile_row = ypixel / TILE_HEIGHT;
tile_col = xpixel / TILE_WIDTH;
......@@ -518,17 +529,27 @@ tile_manager_map (TileManager *tm,
int bottom_tile;
int i, j, k;
/* printf("@");fflush(stdout);*/
if ((level < 0) || (level >= tm->nlevels))
return;
{
g_warning ("tile_manager_map: level out of range.");
return;
}
tile_level = &tm->levels[level];
ntiles = tile_level->ntile_rows * tile_level->ntile_cols;
if ((tile_num < 0) || (tile_num >= ntiles))
return;
{
g_warning ("tile_manager_map: tile out of range.");
return;
}
if (!tile_level->tiles)
{
/* g_warning ("tile_manager_map: empty tile level - init'ing.");*/
tile_level->tiles = g_new (Tile*, ntiles);
tiles = tile_level->tiles;
......@@ -542,6 +563,8 @@ tile_manager_map (TileManager *tm,
{
for (j = 0; j < ncols; j++, k++)
{
/* printf(",");fflush(stdout);*/
tiles[k] = g_new (Tile, 1);
tile_init (tiles[k], tile_level->bpp);
tile_attach (tiles[k], tm, k);
......@@ -553,14 +576,26 @@ tile_manager_map (TileManager *tm,
tiles[k]->eheight = bottom_tile;
}
}
/* g_warning ("tile_manager_map: empty tile level - done.");*/
}
tile_ptr = &tile_level->tiles[tile_num];
/* printf(")");fflush(stdout);*/
TILE_MUTEX_LOCK (*tile_ptr);
tile_detach (*tile_ptr, tm, tile_num);
/* printf(">");fflush(stdout);*/
TILE_MUTEX_LOCK (srctile);
/* printf(" [src:%p tm:%p tn:%d] ", srctile, tm, tile_num); fflush(stdout);*/
tile_attach (srctile, tm, tile_num);
*tile_ptr = srctile;
TILE_MUTEX_UNLOCK (srctile);
/* printf("}");fflush(stdout);*/
}
......@@ -2454,7 +2454,7 @@ copy_region (PixelRegion *src,
{
src_tile = tile_manager_get_tile (src->tiles,
xstepper, ystepper,
0, FALSE, FALSE);
0, TRUE, FALSE);
tile_manager_map_tile (dest->tiles,
xstepper, ystepper, 0,
......
......@@ -2454,7 +2454,7 @@ copy_region (PixelRegion *src,
{
src_tile = tile_manager_get_tile (src->tiles,
xstepper, ystepper,
0, FALSE, FALSE);
0, TRUE, FALSE);
tile_manager_map_tile (dest->tiles,
xstepper, ystepper, 0,
......
......@@ -16,6 +16,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include "tile_cache.h"
#include "tile_manager.h"
#include "tile_swap.h"
......@@ -488,13 +490,22 @@ tile_manager_map_tile (TileManager *tm,
int tile_col;
int tile_num;
/* printf("#");fflush(stdout); */
if ((level < 0) || (level >= tm->nlevels))
return;
{
g_warning ("tile_manager_map_tile: level out of range.");
return;
}
tile_level = &tm->levels[level];
if ((xpixel < 0) || (xpixel >= tile_level->width) ||
(ypixel < 0) || (ypixel >= tile_level->height))
return;
{
g_warning ("tile_manager_map_tile: tile co-ord out of range.");
return;
}
tile_row = ypixel / TILE_HEIGHT;
tile_col = xpixel / TILE_WIDTH;
......@@ -518,17 +529,27 @@ tile_manager_map (TileManager *tm,
int bottom_tile;
int i, j, k;
/* printf("@");fflush(stdout);*/
if ((level < 0) || (level >= tm->nlevels))
return;
{
g_warning ("tile_manager_map: level out of range.");
return;
}
tile_level = &tm->levels[level];
ntiles = tile_level->ntile_rows * tile_level->ntile_cols;
if ((tile_num < 0) || (tile_num >= ntiles))
return;
{
g_warning ("tile_manager_map: tile out of range.");
return;
}
if (!tile_level->tiles)
{
/* g_warning ("tile_manager_map: empty tile level - init'ing.");*/
tile_level->tiles = g_new (Tile*, ntiles);
tiles = tile_level->tiles;
......@@ -542,6 +563,8 @@ tile_manager_map (TileManager *tm,
{
for (j = 0; j < ncols; j++, k++)
{
/* printf(",");fflush(stdout);*/
tiles[k] = g_new (Tile, 1);
tile_init (tiles[k], tile_level->bpp);
tile_attach (tiles[k], tm, k);
......@@ -553,14 +576,26 @@ tile_manager_map (TileManager *tm,
tiles[k]->eheight = bottom_tile;
}
}
/* g_warning ("tile_manager_map: empty tile level - done.");*/
}
tile_ptr = &tile_level->tiles[tile_num];
/* printf(")");fflush(stdout);*/
TILE_MUTEX_LOCK (*tile_ptr);
tile_detach (*tile_ptr, tm, tile_num);
/* printf(">");fflush(stdout);*/
TILE_MUTEX_LOCK (srctile);
/* printf(" [src:%p tm:%p tn:%d] ", srctile, tm, tile_num); fflush(stdout);*/
tile_attach (srctile, tm, tile_num);
*tile_ptr = srctile;
TILE_MUTEX_UNLOCK (srctile);
/* printf("}");fflush(stdout);*/
}
......@@ -1922,9 +1922,11 @@ xcf_load_level (XcfInfo *info,
break;
case COMPRESS_ZLIB:
g_error ("xcf: zlib compression unimplemented");
fail = TRUE;
break;
case COMPRESS_FRACTAL:
g_error ("xcf: fractal compression unimplemented");
fail = TRUE;
break;
}
......@@ -1948,14 +1950,22 @@ xcf_load_level (XcfInfo *info,
{
tile_release (tile, TRUE);
tile_manager_map (tiles, i, level_num, previous);
putchar('M');
}
else
{
tile_release (tile, TRUE);
previous = tile;
putchar('.');
}
tile_release (previous, FALSE);
}
previous = tile;
else
{
previous = tile;
}
/* restore the saved position so we'll be ready to
* read the next offset.
......@@ -1966,6 +1976,8 @@ xcf_load_level (XcfInfo *info,
info->cp += xcf_read_int32 (info->fp, &offset, 1);
}
fflush(stdout);
if (offset != 0)
{
g_message ("encountered garbage after reading level: %d", offset);
......
......@@ -1922,9 +1922,11 @@ xcf_load_level (XcfInfo *info,
break;
case COMPRESS_ZLIB:
g_error ("xcf: zlib compression unimplemented");
fail = TRUE;
break;
case COMPRESS_FRACTAL:
g_error ("xcf: fractal compression unimplemented");
fail = TRUE;
break;
}
......@@ -1948,14 +1950,22 @@ xcf_load_level (XcfInfo *info,
{
tile_release (tile, TRUE);
tile_manager_map (tiles, i, level_num, previous);
putchar('M');
}
else
{
tile_release (tile, TRUE);
previous = tile;
putchar('.');
}
tile_release (previous, FALSE);
}
previous = tile;
else
{
previous = tile;
}
/* restore the saved position so we'll be ready to
* read the next offset.
......@@ -1966,6 +1976,8 @@ xcf_load_level (XcfInfo *info,
info->cp += xcf_read_int32 (info->fp, &offset, 1);
}
fflush(stdout);
if (offset != 0)
{
g_message ("encountered garbage after reading level: %d", offset);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment