diff --git a/ChangeLog b/ChangeLog index c4069c7cbe..b0178816ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Fri Jul 10 23:06:09 BST 1998 Adam D. Moss + + * 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 * app/docindexif.c: New file. diff --git a/app/base/tile-manager.c b/app/base/tile-manager.c index da43cea5ce..33ff5a9c46 100644 --- a/app/base/tile-manager.c +++ b/app/base/tile-manager.c @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include + #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);*/ } diff --git a/app/paint-funcs/paint-funcs.c b/app/paint-funcs/paint-funcs.c index 728cee311b..13c9cd985e 100644 --- a/app/paint-funcs/paint-funcs.c +++ b/app/paint-funcs/paint-funcs.c @@ -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, diff --git a/app/paint_funcs.c b/app/paint_funcs.c index 728cee311b..13c9cd985e 100644 --- a/app/paint_funcs.c +++ b/app/paint_funcs.c @@ -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, diff --git a/app/tile_manager.c b/app/tile_manager.c index da43cea5ce..33ff5a9c46 100644 --- a/app/tile_manager.c +++ b/app/tile_manager.c @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include + #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);*/ } diff --git a/app/xcf.c b/app/xcf.c index f30186b64e..6f07a65ae8 100644 --- a/app/xcf.c +++ b/app/xcf.c @@ -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); diff --git a/app/xcf/xcf.c b/app/xcf/xcf.c index f30186b64e..6f07a65ae8 100644 --- a/app/xcf/xcf.c +++ b/app/xcf/xcf.c @@ -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);