From: SourceForge.net <no...@so...> - 2003-05-13 20:39:56
|
Bugs item #220783, was opened at 2000-11-01 00:53 Message generated for change (Comment added) made by dkf You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112997&aid=220783&group_id=12997 Category: 40. Bitmap Images Group: = 8.0.3 Status: Open Resolution: None >Priority: 6 Submitted By: Brent B. Welch (welch) Assigned to: Donal K. Fellows (dkf) Summary: [BITMAP config -maskdata $data] doesn't work Initial Comment: OriginalBugID: 970 Bug Version: 8.0.3 SubmitDate: '1998-12-15' LastModified: '1999-08-15' Severity: MED Status: Assigned Submitter: welch ChangedBy: hobbs OS: Linux-Red Hat Machine: Other Name: D. Richard Hipp CustomShell: Plus/Dash patches ReproducibleScript: image create bitmap t1 -data $data -maskdata $data -background red label .x -image t1 pack .x update t1 config -maskdata $NewMaskData ObservedBehavior: The new mask specified by the "configure" does not take effect. DesiredBehavior: I expect the mask to change. Here's a workaround: t1 config -maskdata {} t1 config -maskdata $NewMaskData The problem results from a unfortunate interaction between the XID allocator and the Tk_GetGC allocator. Patch: *** tkImgBmap.c.orig Mon Dec 7 17:45:41 1998 --- tkImgBmap.c Mon Dec 7 18:11:49 1998 *************** *** 353,358 **** --- 353,359 ---- XGCValues gcValues; GC gc; unsigned int mask; + Pixmap oldMask; /* * For each of the options in masterPtr, translate the string *************** *** 395,410 **** (unsigned) masterPtr->height); } ! if (instancePtr->mask != None) { ! Tk_FreePixmap(Tk_Display(instancePtr->tkwin), instancePtr->mask); ! instancePtr->mask = None; ! } if (masterPtr->maskData != NULL) { instancePtr->mask = XCreateBitmapFromData( Tk_Display(instancePtr->tkwin), RootWindowOfScreen(Tk_Screen(instancePtr->tkwin)), masterPtr->maskData, (unsigned) masterPtr->width, (unsigned) masterPtr->height); } if (masterPtr->data != NULL) { --- 396,418 ---- (unsigned) masterPtr->height); } ! /* ! * Careful: We have to allocate a new mask Pixmap before deleting ! * the old one. Otherwise, The XID allocator will always return ! * the same XID for the new Pixmap as was used for the old Pixmap. ! * And that will prevent the mask from changing in the GC below. ! */ ! oldMask = instancePtr->mask; ! instancePtr->mask = None; if (masterPtr->maskData != NULL) { instancePtr->mask = XCreateBitmapFromData( Tk_Display(instancePtr->tkwin), RootWindowOfScreen(Tk_Screen(instancePtr->tkwin)), masterPtr->maskData, (unsigned) masterPtr->width, (unsigned) masterPtr->height); + } + if (oldMask != None) { + Tk_FreePixmap(Tk_Display(instancePtr->tkwin), oldMask); } if (masterPtr->data != NULL) { PatchFiles: tkImgBmap.c This fix is a quick hack. We really need to think long and hard about a better way to fix the interaction between AllocXId() and Tk_GetGC(). It also seems like the same bitmap could be shared across multiple image instances, at least on the same display. Is there any particular reason why this optimization is not done? 02/03/1999 17:17 - stanton - I have applied the suggested patch, but the fundamental problem still exists. The core issue is that Tk_GetGC doesn't notice when an XID is reused for a different object of the same type, so it will return a stale GC. ---------------------------------------------------------------------- >Comment By: Donal K. Fellows (dkf) Date: 2003-05-13 21:39 Message: Logged In: YES user_id=79902 Unless something gets done on this as part of TkGS (e.g. wrapping the pixmap ids in something that lists the GCs to be invalidated when the pixmap is deleted) ensuring that the new id is allocated before the old one is released is probably the only way to take this on. Rats, but that is inelegant. :^/ ---------------------------------------------------------------------- Comment By: Donal K. Fellows (dkf) Date: 2003-02-25 09:41 Message: Logged In: YES user_id=79902 I think I've hit this fairly recently (i.e. since I became a core maintainer...) ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2002-07-05 23:04 Message: Logged In: YES user_id=80530 still valid in 8.4 ? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112997&aid=220783&group_id=12997 |