1
vote
Vote UpVote

TObjectHelper for easier debugging a cast mismatch and a typed FreeAndNil

The Wiert Corner – The below came in really useful in an old project I took over that was full of bugs having to do with improper casts and FreeAndNil usage. First the examples. procedure TMyServer.UnbindFromIdTcpServerStatusContext(const aContext: TIdContext); var lClientSession: TClientSession; begin lClientSession := TObjectHelper.Cast(aContext.Data); ... end; type TBaseDataInterface = class(TObject) strict private FDatabase: TIBDatabase; FTransaction: TIBTransaction; ... end; destructor TBaseDataInterface.Destroy(); begin TObjectHelper.FreeAndNil(FDatabase); ...
Favorite? Off-Topic? jpluimers @ 2018-10-10 07:05

Statistics

Visits: 188
Votes: 1
Favorites: 0
Off-Topic: 0

Visits by Source

User Actions

Users who voted for this posting

Ph. B.
Subscribe:
Contact us to advertise on DelphiFeeds.com

Community Links

Torry Firebird News

Sponsor

 
Please login or register to use this functionality.
(click on this box to dismiss)