Tk Source Code

View Ticket
Login
Ticket UUID: 2830420
Title: wm iconphoto under X11 works only for little endian machines
Type: Bug Version: obsolete: 8.6b1.1
Submitter: cmi5 Created on: 2009-07-31 16:59:54
Subsystem: 67. Unix Window Operations Assigned To: dkf
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2009-11-27 23:24:35
Resolution: Fixed Closed By: dkf
    Closed on: 2009-11-27 16:24:35
Description:
OS: Solaris10 sparc

tk8.6.b1.1 (CVS head)

It looks like the byteorder for the _NET_WM_ICON property is wrong on big endian machines

Suggested patch:

(there may by more efficien ways)
*** tkUnixWm.c.~1.71.~  Fri Apr  3 22:20:17 2009
--- tkUnixWm.c  Fri Jul 31 17:55:35 2009
***************
*** 2425,2435 ****
                        y*block.pitch + block.offset[2]);
                A = *(block.pixelPtr + x*block.pixelSize +
                        y*block.pitch + block.offset[3]);
!               pixelByte = (unsigned char *) &iconPropertyData[index];
!               pixelByte[3] = A;
!               pixelByte[2] = R;
!               pixelByte[1] = G;
!               pixelByte[0] = B;
                index++;
            }
        }
--- 2425,2437 ----
                        y*block.pitch + block.offset[2]);
                A = *(block.pixelPtr + x*block.pixelSize +
                        y*block.pitch + block.offset[3]);
!
!                 /*
!                  * Do not handoptimize the multiplications.
!                  * Let the compiler do its job (think endianess)
!                  */
!                 iconPropertyData[index]= (((A*256)+R)*256+G)*256+B;
!
                index++;
            }
        }
User Comments: dkf added on 2009-11-27 23:24:35:

allow_comments - 1

dkf added on 2009-11-27 23:23:55:

allow_comments - 0

dkf added on 2009-08-01 15:09:50:

allow_comments - 1

Good catch. Went with a variation on this which will also work on 64-bit systems (of any stripe).

Fixed on HEAD and 8.5 branch.