Win32Lib Bug (queryFont and wPuts)

new topic     » topic index » view thread      » older message » newer message

Hi,

Found a resource leak bug in win32lib:

queryFont() and wPuts() both call assignFont() which creates an a
font and an HDC. The HDC is released in both procedures but the font
is not, this lead to a huge resource leak in my app (4,000 GDI Objects
shown in Task Manager rather than 300-400).

It's simple to fix, I pretty much just cut and pasted from win32lib
0.56.
In wPuts put the following lines just before the call to releaseDC:

    -- replace the font with the default again
    replaceObject( id, hdc, DefaultFontID, ForProgram )

And in queryFont() again put the following lines just before the call
to releaseDC:

    -- replace the font with the default again
    replaceObject( useId, hdc, DefaultFontID, ForProgram )

This seems to fix it entirely and have no bad side effects :)

Derek, would it be possible for a bug fix release to be made anytime
soon with this fix and the setBackColor fix I posted on the 9th? I'd
prefer not to have to distribute modified a version of win32lib as then
things would get a little complicated...

Thomas Parslow (PatRat)
E-Mail/Jabber: tom at almostobsolete.net
ICQ: 26359483

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu