This finally block should be modified to reset the format settings to the original in the event of a failure in Write.Write. I believe the retrieval of the format settings should be outside of the try loop, as a global would this ever fail?
If the writer fails, the format settings are not reset.
proposed changes: (should be in save and load procedures)
class procedure TTMSFNCPersistence.SaveSettingsToStream(AObject: TObject;
AStream: TStreamEx);
var
Writer: TTMSFNCWriter;
{$IFDEF WEBLIB}
d, t: string;
{$ENDIF}
{$IFNDEF WEBLIB}
d, t: Char;
{$ENDIF}
begin
Writer := TTMSFNCWriter.Create(AStream);
t := FormatSettings.ThousandSeparator; // should never fail to read
d := FormatSettings.DecimalSeparator; //should never fail to read
try
Writer.IOReference := TTMSFNCPersistence.IOReference;
Writer.RootObject := TTMSFNCPersistence.RootObject;
Writer.OnCustomWriteProperty := DoCustomWriteProperty;
FormatSettings.DecimalSeparator := '.';
FormatSettings.ThousandSeparator := ',';
Writer.Write(AObject);
finally
FormatSettings.DecimalSeparator := d; // always reset to previous value
FormatSettings.ThousandSeparator := t; // always reset to previous value
Writer.Free;
end;
end;