TValueHelper.TryToType is defect

Issue #181 resolved
Sergey Burov created an issue
function TValueHelper.TryToType<T>(out targetValue: T): Boolean;
var
  value: TValue;
begin
  Result := TryConvert(System.TypeInfo(T), value);
  if Result then
  begin
    if TValueData(Self).FTypeInfo = nil then
    begin
      FillChar(Pointer(@targetValue)^, SizeOf(T), 0);
      Exit;
    end;
    ExtractRawData(@targetValue); //maybe this line must look as Value. ExtractRawData(@targetValue);?
  end;
end;

We try use TValueHelper from spring in Knockoff framework. We binding controls and Nullable types fields. And when control value change the program call method

procedure TDependentObservable<T>.SetValue(const value: TValue);
begin
  Invoke(value.ToType<T>);
end;

Wich calling TValueHelper.TryToType. And in fine result Nullable<T> has only fValue without fHasValue.

Comments (4)

  1. Log in to comment