After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 395385 - psd_save fails to save multi-layer images without any visible layers
psd_save fails to save multi-layer images without any visible layers
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Plugins
2.2.x
Other All
: High normal
: 2.2
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2007-01-11 13:40 UTC by T. Takeda
Modified: 2008-01-15 13:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
don't crash be returning early (433 bytes, patch)
2007-02-04 14:52 UTC, Michael Schumacher
needs-work Details | Review
check the return value of gimp_image_flatten (766 bytes, patch)
2007-02-05 17:35 UTC, Sven Neumann
none Details | Review

Description T. Takeda 2007-01-11 13:40:23 UTC
Please describe the problem:
Sometimes, i mistakenly save a psd image without visible layers.
(For example, when I discard a rough-image layer and save the image before turning some other layers visible).
Whenever i do such a manupulation, psd_save.exe crashes.

I use wingimp 2.2.13.
This happens both on win2000/XP.

Steps to reproduce:
1. make multiple-layers 
2. make all laters invisible
3. save .psd file


Actual results:
A message box appears that says psd_save.exe crashes.

Expected results:
A psd file without visible layer should be saved.

Does this happen every time?
yes

Other information:
Comment 1 Michael Schumacher 2007-02-03 22:11:23 UTC
psd_save does add a flattened layer to the psd file for multi-layer images, probably to provide a reference rendering. This fails if no layers are visible (gimp-image-flatten does fail).

The image can't be saved on Linux, either. Changing platform and summary.
Comment 2 Michael Schumacher 2007-02-04 14:52:35 UTC
Created attachment 81875 [details] [review]
don't crash be returning early

Preventing the crash by returning early from write_pixel_data seems to be a trivial solution. This patch was tested with 2.2; I didn't try if any application besides GIMP does load the PSD, though. 

For trunk, drawable id validation could be used.
Comment 3 Sven Neumann 2007-02-04 21:38:56 UTC
The PSD plug-in should probably check the return value of the flatten operation and create an empty drawable as a fallback (if the returned drawable ID is -1).
Comment 4 Sven Neumann 2007-02-05 17:34:53 UTC
I am not an expert but from looking at the code I get the impression that the reference layer is not absolutely needed in a PSD file. So we can probably do a quick fix like the one that Michael suggested.
Comment 5 Sven Neumann 2007-02-05 17:35:28 UTC
Created attachment 81942 [details] [review]
check the return value of gimp_image_flatten
Comment 6 Sven Neumann 2007-02-19 13:35:04 UTC
Perhaps the only way to get this tested is to actually commit it. I've done that now in both branches:

2007-02-19  Sven Neumann  <sven@gimp.org>

	* plug-ins/common/psd_save.c: check the return value of
	gimp_image_flatten(). Fixes the crash reported in bug #395385.