make it work as documented (fail if the new_image already has a display).

2004-11-29  Michael Natterer  <mitch@gimp.org>

	* tools/pdbgen/pdb/display.pdb: make it work as documented (fail
	if the new_image already has a display). Also fail if the
	old_image doesn't have any display (changed docs accordingly).
	On success, take over the initial reference count of the new
	image, just as the gimp_display_new() PDB wrapper does.
	Fixes bug #159051.

	* app/pdb/display_cmds.c
	* libgimp/gimpdisplay_pdb.c: regenerated.
This commit is contained in:
Michael Natterer 2004-11-29 16:59:53 +00:00 committed by Michael Natterer
parent 28d4a760d0
commit 28da246c2a
4 changed files with 54 additions and 14 deletions

View file

@ -1,3 +1,15 @@
2004-11-29 Michael Natterer <mitch@gimp.org>
* tools/pdbgen/pdb/display.pdb: make it work as documented (fail
if the new_image already has a display). Also fail if the
old_image doesn't have any display (changed docs accordingly).
On success, take over the initial reference count of the new
image, just as the gimp_display_new() PDB wrapper does.
Fixes bug #159051.
* app/pdb/display_cmds.c
* libgimp/gimpdisplay_pdb.c: regenerated.
2004-11-29 Sven Neumann <sven@gimp.org>
* app/file/file-save.c (file_save_as): when the image filename

View file

@ -204,7 +204,20 @@ displays_reconnect_invoker (Gimp *gimp,
success = FALSE;
if (success)
gimp_reconnect_displays (gimp, old_image, new_image);
{
success = (old_image != new_image &&
old_image->disp_count > 0 &&
new_image->disp_count == 0);
if (success)
{
gimp_reconnect_displays (gimp, old_image, new_image);
/* take ownership of the image */
if (new_image->disp_count > 0)
g_object_unref (new_image);
}
}
return procedural_db_return_args (&displays_reconnect_proc, success);
}
@ -214,7 +227,7 @@ static ProcArg displays_reconnect_inargs[] =
{
GIMP_PDB_IMAGE,
"old_image",
"The old image (should have at least one display)"
"The old image (must have at least one display)"
},
{
GIMP_PDB_IMAGE,
@ -227,7 +240,7 @@ static ProcRecord displays_reconnect_proc =
{
"gimp_displays_reconnect",
"Reconnect displays from one image to another image.",
"This procedure connects all displays of the old_image to the new_image. If the new_image already has a display the reconnect is not performed and the procedure returns without success. You should rarely need to use this function.",
"This procedure connects all displays of the old_image to the new_image. If the old_image has no display or new_image already has a display the reconnect is not performed and the procedure returns without success. You should rarely need to use this function.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",

View file

@ -122,15 +122,15 @@ gimp_displays_flush (void)
/**
* gimp_displays_reconnect:
* @old_image_ID: The old image (should have at least one display).
* @old_image_ID: The old image (must have at least one display).
* @new_image_ID: The new image (must not have a display).
*
* Reconnect displays from one image to another image.
*
* This procedure connects all displays of the old_image to the
* new_image. If the new_image already has a display the reconnect is
* not performed and the procedure returns without success. You should
* rarely need to use this function.
* new_image. If the old_image has no display or new_image already has
* a display the reconnect is not performed and the procedure returns
* without success. You should rarely need to use this function.
*
* Returns: TRUE on success.
*/

View file

@ -89,27 +89,42 @@ HELP
);
}
sub displays_reconnect {
$blurb = 'Reconnect displays from one image to another image.';
$help = <<'HELP';
This procedure connects all displays of the old_image to the new_image.
If the new_image already has a display the reconnect is not performed and the
procedure returns without success. You should rarely need to use this
function.
This procedure connects all displays of the old_image to the
new_image. If the old_image has no display or new_image already has a
display the reconnect is not performed and the procedure returns
without success. You should rarely need to use this function.
HELP
&std_pdb_misc;
@inargs = (
{ name => 'old_image', type => 'image',
desc => 'The old image (should have at least one display)' },
desc => 'The old image (must have at least one display)' },
{ name => 'new_image', type => 'image',
desc => 'The new image (must not have a display)' }
);
%invoke = ( code => 'gimp_reconnect_displays (gimp, old_image, new_image);' );
%invoke = ( code => <<'CODE'
{
success = (old_image != new_image &&
old_image->disp_count > 0 &&
new_image->disp_count == 0);
if (success)
{
gimp_reconnect_displays (gimp, old_image, new_image);
/* take ownership of the image */
if (new_image->disp_count > 0)
g_object_unref (new_image);
}
}
CODE
);
}
@headers = qw("core/gimp.h");