Nándor Kiss I sometimes write such code for debugging purpose, to be able to put a breakpoint on FreeAndNil in order to verify is the variable has been assigned in a particular test case. This code should be simplifyed later but sometimes it is forgotten.
var tmpVar: Variant; ... tmpVar := SomeFunctionReturningVariant(...); if not(VarIsEmpty(tmpVar) or VarIsNull(tmpVar)) then SomeString := VarToStr(tmpVar) else SomeString := '';
repeated more than 20 times with different arguments to function and different string variables
;-)
ReplyDeleteif Assigned(FLock) then
ReplyDeleteFreeAndNil(FLock);
:)
Wow! No new uglies? How can that be? Oh, wait, you haven't opened any code today? ;)
ReplyDeleteNándor Kiss I sometimes write such code for debugging purpose, to be able to put a breakpoint on FreeAndNil in order to verify is the variable has been assigned in a particular test case. This code should be simplifyed later but sometimes it is forgotten.
ReplyDeleteYesterday I ran into this kind of code:
ReplyDeleteclass procedure TfrmChild.DoSomething;
begin
frmChild.SomeProperty := 10;
frmChild.ThisAndThat;
end;
var
ReplyDeletetmpVar: Variant;
...
tmpVar := SomeFunctionReturningVariant(...);
if not(VarIsEmpty(tmpVar) or VarIsNull(tmpVar)) then
SomeString := VarToStr(tmpVar)
else
SomeString := '';
repeated more than 20 times with different arguments to function and different string variables