1. Win32lib Tooltips problem

Hi all,

Here is a problem with win32lib that I thought I would throw out to
everyone.  In the sample program included below, hints (tooltips) are set
for different buttons.  After about 150 hints have been displayed (say, by
going around and clicking different buttons with the mouse) you will get
this fatal error:

       EZCreateFont:SaveDC

Sometimes the error is slightly different (createCompatibleDC or something
like that).

I discovered this with win32lib .45b but also tried it on .45i which has
the same behavior.

A sample program that will cause the problem is included below.

I looked around a bit in win32lib to see what might cause the problem, but
since I'm not too sure even what DCs are, I didn't get too far.

Does anybody have an idea what might cause this or how to solve it?

--Brent



--sample program----------------------------------------------------------

include win32lib.ew -- David Cuny library

global constant
   EarTestX=623,
   EarTestY=421,
   EarTest =create(Window, "EarTest", 0,Default,Default,EarTestX,EarTestY,0)


constant NoteNames = {"C", "C#", "D", "Eb", "E", "F", "F#", "G", "Ab", "A",
"Bb", "B"}
integer xKey, yKey, yTxtKey
atom XSKey, YSKey
xKey = 10 --Keyboard, upperleftx
yKey = 10
yTxtKey = 354
XSKey = 290/200 --Keyboard, "stretch"
YSKey = 150/200

integer btC, btD, btE, btF, btG, btA, btB, btCs, btDs, btFs, btGs, btAs, btC2
sequence bts




   btC = create(PushButton, NoteNames [1], EarTest, xKey + XSKey *
(0),         yKey, XSKey*22, YSKey * 150, 0)
   btD = create(PushButton, NoteNames [3], EarTest, xKey + XSKey *
(38),        yKey, XSKey*22, YSKey * 150, 0)
   btE = create(PushButton, NoteNames [5], EarTest, xKey + XSKey *
(75),        yKey, XSKey*22, YSKey * 150, 0)
   btF = create(PushButton, NoteNames [6], EarTest, xKey + XSKey *
(97),        yKey, XSKey*22, YSKey * 150, 0)
   btG = create(PushButton, NoteNames [8], EarTest, xKey + XSKey *
(38+97),     yKey, XSKey*22, YSKey * 150, 0)
   btA = create(PushButton, NoteNames [10], EarTest, xKey + XSKey *
(75+97),     yKey, XSKey*22, YSKey * 150, 0)
   btB = create(PushButton, NoteNames [12], EarTest, xKey + XSKey *
(75+97+38),  yKey, XSKey*22, YSKey * 150, 0)
   btC2 = create(PushButton, NoteNames [1],EarTest, xKey + XSKey *
(75+97+60),  yKey, XSKey*22, YSKey * 150, 0)

   btCs = create(PushButton, NoteNames [2], EarTest, xKey + XSKey *
(20),       yKey, XSKey*20, YSKey * 120, 0)
   btDs = create(PushButton, NoteNames [4], EarTest, xKey + XSKey *
(58),       yKey, XSKey*20, YSKey * 120, 0)
   btFs = create(PushButton, NoteNames [7], EarTest, xKey + XSKey *
(20+97),    yKey, XSKey*20, YSKey * 120, 0)
   btGs = create(PushButton, NoteNames [9], EarTest, xKey + XSKey *
(58+97),    yKey, XSKey*20, YSKey * 120, 0)
   btAs = create(PushButton, NoteNames [11], EarTest, xKey + XSKey *
(58+97+38), yKey, XSKey*20, YSKey * 120, 0)

   bts= {btC, btD, btE, btF, btG, btA, btB, btCs, btDs, btFs, btGs, btAs,
btC2 }
   --set 0s
   for y = 1 to 13 do
      setHint( bts[y], "To answer, click here (or use Keyboard Shortcuts)")
   end for


WinMain(EarTest, Normal)


--end of sample






+++++++++++++++++++ Brent Hugh / bhugh at griffon.mwsc.edu ++++++++++++++++++
+   Missouri Western State College Dept of Music, St. Joseph, Missouri   +
+               Piano Home Page: http://www.mwsc.edu/~bhugh              +
+ Internet Piano Concert:  http://cctr.umkc.edu/userx/bhugh/recital.html +
++++++++++ Classical Piano MP3s http://www.mp3.com/brent_d_hugh ++++++++++

new topic     » topic index » view message » categorize

2. Re: Win32lib Tooltips problem

Brent Hugh wrote:

> After about 150 hints have been displayed
> (say, by going around and clicking different
> buttons with the mouse) you will get this fatal
> error:
>
>        EZCreateFont:SaveDC

*sigh*

It's a bug that's been in Win32Lib for some time - I keep hoping that I've
solved it, but obviously I haven't. It only shows up when a *custom* font is
involved.

In Win32Lib, I emulate tooltips, for reasons better not explained here.
There's been a change a few minor versions to the 0.45; one of them has been
to change the font used in tooltips DefaultFontID from SYSTEM_FONT to
ANSI_VAR_FONT. Since this is a custom font, the problem crops up. If you
change this back to SYSTEM_FONT (around line 4245 in the latest bleeding
edge), the problem should disappear - or at least, slow down.

That's just a temporary fix. The problem is a resource leak, but I'm not
sure what's leaking, or where it's leaking. I *suspected* that fonts are
being created without the older fonts being released. But this doesn't seem
to match your error message. So I now suspect that DCs are being created,
and never destroyed. Every time Win32Lib tries to perform a graphic
operation, it gets a DC (unless it's already created, such as in an
onPaint). It *sounds* like somewhere the DC is never being released.

When I ran Win32Lib applications under WINE, I got some error messages that
indicated that this might be the case. I've been through the code several
times, trying to find where the leak might be. I'll put your bug at the top
of my list. In the mean time, changing the value of DefaultFontID back to
SYSTEM_FONT *should* take care of the problem for the moment.

Sorry about that.

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu