Probably the programmer has refactored from using objects to using interfaces recently and - as the parameter of FreeAndNil is typeless and no compiler hint is given - forgot to remove this. However... I've seen much worse... interface methods like "FreeOnNextReleaseCall". Guess, what it is doing? I had much fun debugging AVs due to such ingenious ideas... :-/
Somebody who changed an object reference to an interface without realizing this consequence. (Yes, I am guilty of this. It took me forever to figure out the reason for the weird AVs that were caused by this.)
Sorry guys, but for Delphi N00bs like I am , EMB doesn't show the example ... look at the procedure procedure TMyThread.OnTerminate in the delphi code :
(-_^) whaaa?!
ReplyDeleteProbably the programmer has refactored from using objects to using interfaces recently and - as the parameter of FreeAndNil is typeless and no compiler hint is given - forgot to remove this. However... I've seen much worse... interface methods like "FreeOnNextReleaseCall". Guess, what it is doing? I had much fun debugging AVs due to such ingenious ideas... :-/
ReplyDeleteSomebody who changed an object reference to an interface without realizing this consequence. (Yes, I am guilty of this. It took me forever to figure out the reason for the weird AVs that were caused by this.)
ReplyDelete@Thomas: you can rest assured as this is easy to forget doing such a refactoring (see my comment above why).
ReplyDeleteStefan Meisner LOL -- argh! It was my sick twisted mind! I changed the class to an interface. Oh the shame! ;-)
ReplyDeleteOkay, this is yet another reason to never use FreeAndNil -- if Free were uses, the compiler would have let me know! ;-)
Nick Hodges interface strikes back, part 1! ((:
ReplyDeleteNick Hodges I was wondering when someone would say to "never us FreeAndNil" but its funny that yourself are the one ;-D
ReplyDeleteA freeandhihilist , of course.
ReplyDeleteHow did he live with the exception?
ReplyDeleteTry
FreeAndNil(intf);
Finally
Inherited Destroy;
End;
?
Sorry guys, but for Delphi N00bs like I am , EMB doesn't show the example ... look at the procedure procedure TMyThread.OnTerminate in the delphi code :
ReplyDeletehttp://docwiki.embarcadero.com/CodeExamples/XE2/en/TThreadYield_(Delphi)
Honestly, coming from the bargage collector world, all this debate about FreeAndNil let me totally... puzzled
That is some seriously retarded thread code!
ReplyDeleteSimon Stuart have you laughed at "synchronize everything and everywhere in the thread" thing?
ReplyDelete