Recent

Author Topic: TFONT and related init ?  (Read 199 times)

jamie

  • Hero Member
  • *****
  • Posts: 7774
TFONT and related init ?
« on: May 21, 2026, 12:17:36 pm »
The help indicates if a TFont is created there is a delayed flag that indicates the resource handle is created when it is selected into the canvas, this is greate if true.

 However, what hapoens to a font that gets replaced in a canvas, does the handle get released?

This also applies with pens and brushes?
The only true wisdom is knowing you know nothing

Thaddy

  • Hero Member
  • *****
  • Posts: 19273
  • Glad to be alive.
Re: TFONT and related init ?
« Reply #1 on: May 22, 2026, 02:25:40 pm »
Can't you simply examine the code? Then you know the answer.
Happy to do that for you.....when required.

Lazarus has excellent features to analyse this, simply by selection and ask for declaration and then implementation (crtl-shift-down arrow).

Can you explain why such an experienced programmer like you did not already do so?

In this case, you will notice that - following all the way to TPersistent if you want  - the handle becomes invalid for the old font. There is no reason to release the old one. The handle is not the resource. But you can not re-use that old handle. On most platforms the handle is just a pointer and not a resource.
It won't leak...

(maybe you are a bit confused that in Win16 handles would leak and were limited?)
On Win32+ and Linux you can ignore handle management other than that done in the sources.

Hope that helps... took 20 seconds...
« Last Edit: May 22, 2026, 02:53:13 pm by Thaddy »
objects are fine constructs. You can even initialize them with constructors.

 

TinyPortal © 2005-2018