Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!igor!twinkie!drk From: drk@twinkie.Rational.COM (David Kaelbling) Newsgroups: comp.windows.x Subject: Multiple GCs sharing fonts vs. XFreeGC Keywords: GC,font,sharing,BadFont Message-ID: <625@igor.Rational.COM> Date: 11 Apr 90 22:10:10 GMT Sender: news@Rational.COM Lines: 29 I've run into problems sharing fonts in a widget I'm writing, and wondered if anyone could straighten me out. I'm running X.V11R4 with fixes 1..9 installed on a Sun 3/80 under SunOS 4.0.3. Everything is compiled with gcc-1.35. My widget has a font resource which supplies (via the usual toolkit magic) a default XFontStruct*. I create several GCs using this default font->fid. All goes smoothly until I attempt to exit. When my destroy procedure calls XFreeGC on the second GC I created, it dies with a BadFont error. Xscope reveals that the first call to XFreeGC issued a CloseFont request which released my font_id! Having several GCs using the same font id doesn't seem like too radical an idea (I don't see any way to reconstruct a font name for another call XLoadFont), and I didn't see any red flags in the documentation about common pitfalls. My fid is a real font id, not a context id in disquise. Somebody else must have tried this. Where have I gone wrong? (It's only obvious if you understand it?) Thanks, David (drk@Rational.COM) PS: Why, oh why, doesn't the toolkit manage fonts and XFontStructs? -- David Kaelbling (408) 496-3600 c/o Rational; 3320 Scott Boulevard; Santa Clara, CA 95054-3197 Email: drk@Rational.COM, or uucp {uunet,ubvax,amdcad,aeras}!igor!drk