[Gambas-user] Class behavior: _free method

T Lee Davidson t.lee.davidson at gmail.com
Thu Dec 15 18:08:33 CET 2022

On 12/15/22 10:51, CD wrote:
> Hello
> I join a test project that gives me 3 problems
> 1°) the class name during the instantiation is forced with a capital letter:
> clsTestClass becomes ClsTestClass.

It doesn't behave that way here. I can choose "clsTestClass" from the auto-completion dropdown which also shows the public 
symbols of the class.

> 2°) As I must share the same instance between several procedures, I declare it
> without instantiating it in the declarations.
> But when I instantiated it in one of the procedures, Gambas does not offer me
> the public members of the class.

The program behaves as expected here even using the uppercase class name, "ClsTestClass". When having difficulties such as this, 
it might help to "Compile all" to make the IDE aware of new classes and/or class properties and methods.

> 3°) The class contains a Timer, and when I free the instance, I thought I could
> free the Timer. It does not work!
> First I have to free the Timer from outside the class, so that I can free the
> instance afterwards...

There was a discussion of this some time ago. I think it was in regards to me trying unsuccessfully to close open sockets in the 
_free method. The issue, IIRC, was caused by the sequence of events that happen when a resource is freed, and, yes, it is to be 
expected. Unfortunately, I don't recall exactly how Benoît explained it. I'll have to see if I can find that discussion in the 
mailing list archive.


More information about the User mailing list