Path: utzoo!attcan!uunet!ogicse!mintaka!bloom-beacon!ATHENA.MIT.EDU!swick From: swick@ATHENA.MIT.EDU (Ralph R. Swick) Newsgroups: comp.windows.x Subject: Re: Multiple GCs sharing fonts vs. XFreeGC Message-ID: <9004131331.AA26865@lyre.MIT.EDU> Date: 13 Apr 90 13:31:45 GMT References: <625@igor.Rational.COM> Sender: daemon@athena.mit.edu (Mr Background) Organization: DEC/MIT Project Athena Lines: 61 I'm running X.V11R4 with fixes 1..9 installed Xscope reveals that the first call to XFreeGC issued a CloseFont request which released my font_id! There's something missing here. XFreeGC does not cause a CloseFont in the sources I'm looking at (nor should it!). Having several GCs using the same font id doesn't seem like too radical an idea No, it's not at all radical -- in fact, it's quite normal. Somebody else must have tried this. You bet. Just to make sure, I've attached below some patches that you may apply to examples/Xaw/xcommand.c and test the libraries you're really using. PS: Why, oh why, doesn't the toolkit manage fonts and XFontStructs? More than the resource conversion cache does, you mean? Maybe you should describe what additional mechanisms you'd like. -Ralph. -------- Test case: apply the following to examples/Xaw/xcommand.c, making a new file /tmp/gctest.c. Each time you press the button, a new GC will be created and destroyed using a single common font. Also, the button will be re-drawn using the same font id. *** /x/examples/Xaw/xcommand.c Fri Dec 15 19:37:16 1989 --- /tmp/gctest.c Fri Apr 13 09:24:28 1990 *************** *** 88,94 **** Widget w; XtPointer call_data, client_data; { ! fprintf(stdout, "Button Selected.\n"); } /* Function Name: Syntax --- 88,102 ---- Widget w; XtPointer call_data, client_data; { ! GC gc; ! XGCValues values; ! XFontStruct *font; ! ! XtVaGetValues(w, XtNfont, (XtArgVal)&font, NULL); ! values.font = font->fid; ! gc = XCreateGC(XtDisplay(w), XtWindow(w), GCFont, &values); ! printf("font id = %x; gc id = %x\n", values.font, gc->gid); ! XFreeGC(XtDisplay(w),gc); } /* Function Name: Syntax