Lines 937-946 of tkImgPhoto.c loop
through the photo image formats
on the formatList seeking one which
will support the -format.
There's no following loop through
the oldFormatList. This means if
the requested -format is implemented
via either.
Tk_CreateOldPhotoImageFormat()
or
#define USE_OLD_IMAGE
Tk_CreatePhotoImageFormat()
then it's offered stringWriteProc will
just be ignored.
This bug may have been around since
the change in photo image formats (8.2?).
We might have caught it, except none of
the built-in photo image formats supports
a stringWriteProc, and thus we have no
tests of the [image data -format] command.
Logged In: YES
user_id=79902
Odd. We *used* to scan the old format list for a
stringWriteProc, but that was removed in version 1.17 of
tkImgPhoto.c, and the changelog isn't instructive. We're
just referred to documentation which doesn't actually
explain anything from the PoV of today.
Logged In: YES
user_id=79902
BTW, these changes happened for the 8.3.0 release, and were
a consequence of Jeff checking in changes proposed by Jan
Nijtmans.
Logged In: YES
user_id=79902
Fixed
Logged In: YES
user_id=80530
Ah, that makes a bit more sense.
Turns out [$image data] is
new in Tk 8.3, and apparently
was introduced supporting only
the new interface.
Logged In: YES
user_id=72656
please backport to core-8-4-branch as well.
Logged In: YES
user_id=80530
better fix it before spreading it. :/
With the fairly small test.ppm
file attached, try:
% [image create photo -file test.ppm] data -format ppm
Program received signal SIGSEGV, Segmentation fault.
0x12009d190 in StringWritePPM (interp=0x120374ee0,
format=0x11fffea60,
blockPtr=0x12040a010) at
/local/src/tk/unix/../generic/tkImgPPM.c:393
393 *byteArray++ = pixelPtr[0];
(gdb) bt
#0 0x12009d190 in StringWritePPM (interp=0x120374ee0,
format=0x11fffea60,
blockPtr=0x12040a010) at
/local/src/tk/unix/../generic/tkImgPPM.c:393
#1 0x12009ebd4 in ImgPhotoCmd (clientData=0x12040a1d0,
interp=0x120374ee0,
objc=4, objv=0x120376898) at
/local/src/tk/unix/../generic/tkImgPhoto.c:986
#2 0x120129db8 in TclEvalObjvInternal (interp=0x120374ee0,
objc=4,
objv=0x120376898, command=0x0, length=0, flags=0)
at ./../generic/tclBasic.c:3132
#3 0x12017a99c in TclExecuteByteCode (interp=0x120374ee0,
codePtr=0x12040a050)
at ./../generic/tclExecute.c:1548
#4 0x120178c3c in TclCompEvalObj (interp=0x120374ee0,
objPtr=0x1203832d0)
at ./../generic/tclExecute.c:1005
#5 0x12012b5c8 in Tcl_EvalObjEx (interp=0x120374ee0,
objPtr=0x1203832d0,
flags=131072) at ./../generic/tclBasic.c:3873
#6 0x1201932c4 in Tcl_RecordAndEvalObj (interp=0x120374ee0,
cmdPtr=0x1203832d0, flags=131072) at
./../generic/tclHistory.c:142
#7 0x120193078 in Tcl_RecordAndEval (interp=0x120374ee0,
cmd=0x120383d88 "[image create photo -file test.ppm]
data -format ppm\n",
flags=131072) at ./../generic/tclHistory.c:62
#8 0x12001cd70 in StdinProc (clientData=0x1203e1170, mask=2)
at /local/src/tk/unix/../generic/tkMain.c:370
#9 0x1201a25d8 in Tcl_NotifyChannel (channel=0x1203e1170,
mask=2)
at ./../generic/tclIO.c:6805
#10 0x120209adc in FileHandlerEventProc (evPtr=0x1203f7930,
flags=-3)
---Type <return> to continue, or q <return> to quit---
at ./../unix/tclUnixNotfy.c:625
#11 0x1201c1940 in Tcl_ServiceEvent (flags=-3) at
./../generic/tclNotify.c:625
#12 0x1201c1f50 in Tcl_DoOneEvent (flags=-3) at
./../generic/tclNotify.c:930
#13 0x1200ed164 in Tk_MainLoop ()
at /local/src/tk/unix/../generic/tkEvent.c:1627
#14 0x12001cb60 in Tk_MainEx (argc=1, argv=0x11ffff4f8,
appInitProc=0x12001c300 <Tcl_AppInit>, interp=0x120374ee0)
at /local/src/tk/unix/../generic/tkMain.c:298
#15 0x12001c2d8 in main (argc=1, argv=0x11ffff4f8)
at /local/src/tk/unix/tkAppInit.c:68
Logged In: YES
user_id=80530
StringWritePPM receives
blockPtr->width == 7794320
which appears to lead to the problem.
Logged In: YES
user_id=80530
Note carefully the PORTABILITY
section on Tk_CreatePhotoImageFormat().
Image formats with names in all upper
case get treated as the old interface
style. Formats using the new interface
(like the updated PPM) need to have
names in lower case.
Changing "PPM" to "ppm" on line 56
of tkImgPPM.c corrects the errors I
was seeing.
Yes that feature really is documented.
It's not documented what was being
smoked when it was created. :-)
Logged In: YES
user_id=80530
fix committed to HEAD.
Left open for dkf to backport.
Logged In: YES
user_id=79902
backported