Fixed the tile-corruption bug which has been around since early GIMP-1.1.

Sun Jan 31 19:42:26 GMT 1999 Adam D. Moss <adam@gimp.org>

	* app/tile.c app/tile_manager.c:

	Fixed the tile-corruption bug which has been around
	since early GIMP-1.1.  When dirtying a copy-on-write
	tile, a pointer to nonsense data was being returned
	when the c-o-w'd tile source was swapped out to disk.
	Now the c-o-w'ing routine ensures that the tile data
	is correctly locked into memory before duplicating it
	for dirtying.
This commit is contained in:
GMT 1999 Adam D. Moss 1999-01-31 20:52:15 +00:00 committed by Adam D. Moss
parent f1827884d5
commit 4afd1e88a9
5 changed files with 52 additions and 56 deletions

View File

@ -1,3 +1,15 @@
Sun Jan 31 19:42:26 GMT 1999 Adam D. Moss <adam@gimp.org>
* app/tile.c app/tile_manager.c:
Fixed the tile-corruption bug which has been around
since early GIMP-1.1. When dirtying a copy-on-write
tile, a pointer to nonsense data was being returned
when the c-o-w'd tile source was swapped out to disk.
Now the c-o-w'ing routine ensures that the tile data
is correctly locked into memory before duplicating it
for dirtying.
Sun Jan 31 17:13:46 GMT 1999 Andy Thomas <alt@picnic.demon.co.uk>
Changed:-

View File

@ -152,6 +152,11 @@ tile_manager_get (TileManager *tm,
tile_ptr = &tm->tiles[tile_num];
if (wantwrite && !wantread)
{
g_warning("WRITE-ONLY TILE... OUCHIE");
}
if (wantread)
{
TILE_MUTEX_LOCK (*tile_ptr);
@ -170,6 +175,13 @@ tile_manager_get (TileManager *tm,
newtile->data = g_new (guchar, tile_size (newtile));
memcpy (newtile->data, (*tile_ptr)->data, tile_size (newtile));
}
else
{
tile_lock (*tile_ptr);
newtile->data = g_new (guchar, tile_size (newtile));
memcpy (newtile->data, (*tile_ptr)->data, tile_size (newtile));
tile_release (*tile_ptr, FALSE);
}
tile_detach (*tile_ptr, tm, tile_num);
TILE_MUTEX_LOCK (newtile);
tile_attach (newtile, tm, tile_num);
@ -387,6 +399,7 @@ tile_manager_map (TileManager *tm,
}
tile_detach (*tile_ptr, tm, tile_num);
/* printf(">");fflush(stdout);*/
TILE_MUTEX_LOCK (srctile);
@ -395,6 +408,7 @@ tile_manager_map (TileManager *tm,
tile_attach (srctile, tm, tile_num);
*tile_ptr = srctile;
TILE_MUTEX_UNLOCK (srctile);
/* printf("}");fflush(stdout);*/

View File

@ -8,31 +8,6 @@
#include "libgimp/gimpintl.h"
/* EXPERIMENTAL Copy-On-Write goodies
* by Adam D. Moss
* adam@gimp.org
* adam@foxbox.org
*
*
* C.O.W. Revisions:
*
* 97.10.05 - Initial release
* 97.10.06 - Much faster tile invalidation +
* Better swap interaction (should no longer
* crash GIMP when GIMP swapfile is full).
* 97.10.18 - Very stable now, and even more efficient.
* 98.06.16 - Revised from GIMP 0.99.14 for 1.[01].0 - no
* longer so sure about stability until
* more comprehensive testing is done.
*
*
* MISC TODO:
*
* tile_invalidate: (tile_manager) - don't let a tile become
* invalidated if its ref-count >1, but move it to a delete-on-last-unref
* list instead...
*/
static void tile_destroy (Tile *tile);
@ -273,12 +248,15 @@ tile_detach (Tile *tile, void *tm, int tile_num)
TileLink *tmp;
#ifdef TILE_DEBUG
g_print("tile_detach: %p ~> (%p,%d) *%d\n", tile, tm, tile_num, tile->share_count);
g_print("tile_detach: %p ~> (%p,%d) r%d *%d\n", tile, tm, tile_num,
tile->ref_count, tile->share_count);
#endif
for (link = &tile->tlink; *link; link = &(*link)->next)
if ((*link)->tm == tm && (*link)->tile_num == tile_num)
break;
{
if ((*link)->tm == tm && (*link)->tile_num == tile_num)
break;
}
if (*link == NULL)
{

View File

@ -8,31 +8,6 @@
#include "libgimp/gimpintl.h"
/* EXPERIMENTAL Copy-On-Write goodies
* by Adam D. Moss
* adam@gimp.org
* adam@foxbox.org
*
*
* C.O.W. Revisions:
*
* 97.10.05 - Initial release
* 97.10.06 - Much faster tile invalidation +
* Better swap interaction (should no longer
* crash GIMP when GIMP swapfile is full).
* 97.10.18 - Very stable now, and even more efficient.
* 98.06.16 - Revised from GIMP 0.99.14 for 1.[01].0 - no
* longer so sure about stability until
* more comprehensive testing is done.
*
*
* MISC TODO:
*
* tile_invalidate: (tile_manager) - don't let a tile become
* invalidated if its ref-count >1, but move it to a delete-on-last-unref
* list instead...
*/
static void tile_destroy (Tile *tile);
@ -273,12 +248,15 @@ tile_detach (Tile *tile, void *tm, int tile_num)
TileLink *tmp;
#ifdef TILE_DEBUG
g_print("tile_detach: %p ~> (%p,%d) *%d\n", tile, tm, tile_num, tile->share_count);
g_print("tile_detach: %p ~> (%p,%d) r%d *%d\n", tile, tm, tile_num,
tile->ref_count, tile->share_count);
#endif
for (link = &tile->tlink; *link; link = &(*link)->next)
if ((*link)->tm == tm && (*link)->tile_num == tile_num)
break;
{
if ((*link)->tm == tm && (*link)->tile_num == tile_num)
break;
}
if (*link == NULL)
{

View File

@ -152,6 +152,11 @@ tile_manager_get (TileManager *tm,
tile_ptr = &tm->tiles[tile_num];
if (wantwrite && !wantread)
{
g_warning("WRITE-ONLY TILE... OUCHIE");
}
if (wantread)
{
TILE_MUTEX_LOCK (*tile_ptr);
@ -170,6 +175,13 @@ tile_manager_get (TileManager *tm,
newtile->data = g_new (guchar, tile_size (newtile));
memcpy (newtile->data, (*tile_ptr)->data, tile_size (newtile));
}
else
{
tile_lock (*tile_ptr);
newtile->data = g_new (guchar, tile_size (newtile));
memcpy (newtile->data, (*tile_ptr)->data, tile_size (newtile));
tile_release (*tile_ptr, FALSE);
}
tile_detach (*tile_ptr, tm, tile_num);
TILE_MUTEX_LOCK (newtile);
tile_attach (newtile, tm, tile_num);
@ -387,6 +399,7 @@ tile_manager_map (TileManager *tm,
}
tile_detach (*tile_ptr, tm, tile_num);
/* printf(">");fflush(stdout);*/
TILE_MUTEX_LOCK (srctile);
@ -395,6 +408,7 @@ tile_manager_map (TileManager *tm,
tile_attach (srctile, tm, tile_num);
*tile_ptr = srctile;
TILE_MUTEX_UNLOCK (srctile);
/* printf("}");fflush(stdout);*/