tvplanit: Fix ini datastore crashing when reading an old file.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5166 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-09-15 20:55:30 +00:00
parent e6b2345010
commit 7b7a2ef242

View File

@ -211,6 +211,9 @@ begin
FFormatSettings.DateSeparator := '/';
FFormatSettings.TimeSeparator := ':';
FDayBuffer := 1000*365; // 1000 years, i.e. deactivate daybuffer mechanism
// For testing of compatibility:
// FIniVersionWrite := iv104;
end;
destructor TVpIniDatastore.Destroy;
@ -224,10 +227,13 @@ var
L: TVpIniStrings;
begin
case FIniVersionWrite of
iv104: L := TVpIniStrings_v104.Create(@FFormatSettings);
iv105: L := TVpIniStrings_v105.Create(@FFormatSettings);
else raise Exception.CreateFmt('Writing of ini version "%s" not supported.',
[GetEnumName(TypeInfo(TVpIniVersion), ord(FIniVersionWrite))]);
iv104:
L := TVpIniStrings_v104.Create(@FFormatSettings);
iv105:
L := TVpIniStrings_v105.Create(@FFormatSettings);
else
raise Exception.CreateFmt('Writing of ini version "%s" not supported.',
[GetEnumName(TypeInfo(TVpIniVersion), ord(FIniVersionWrite))]);
end;
try
L.AddField('FirstName', AContact.FirstName); // 0
@ -302,10 +308,13 @@ var
L: TVpIniStrings;
begin
case FIniVersionWrite of
iv104: L := TVpIniStrings_v104.Create(@FFormatSettings);
iv105: L := TVpIniStrings_v105.Create(@FFormatSettings);
else raise Exception.CreateFmt('Writing of ini version "%s" not supported.',
[GetEnumName(TypeInfo(TVpIniVersion), ord(FIniVersionWrite))]);
iv104:
L := TVpIniStrings_v104.Create(@FFormatSettings);
iv105:
L := TVpIniStrings_v105.Create(@FFormatSettings);
else
raise Exception.CreateFmt('Writing of ini version "%s" not supported.',
[GetEnumName(TypeInfo(TVpIniVersion), ord(FIniVersionWrite))]);
end;
try
L.AddDateTimeField('StartTime', AEvent.StartTime, 'c'); // short date + long time
@ -375,10 +384,13 @@ var
L: TVpIniStrings;
begin
case FIniVersionWrite of
iv104: L := TVpIniStrings_v104.Create(@FFormatSettings);
iv105: L := TVpIniStrings_v105.Create(@FFormatSettings);
else raise Exception.CreateFmt('Writing of ini version "%s" not supported.',
[GetEnumName(TypeInfo(TVpIniVersion), ord(FIniVersionWrite))]);
iv104:
L := TVpIniStrings_v104.Create(@FFormatSettings);
iv105:
L := TVpIniStrings_v105.Create(@FFormatSettings);
else
raise Exception.CreateFmt('Writing of ini version "%s" not supported.',
[GetEnumName(TypeInfo(TVpIniVersion), ord(FIniVersionWrite))]);
end;
try
L.AddField('Description', AResource.Description); // 0
@ -439,10 +451,13 @@ var
L: TVpIniStrings;
begin
case FIniVersionWrite of
iv104: L := TVpIniStrings_v104.Create(@FFormatSettings);
iv105: L := TVpIniStrings_v105.Create(@FFormatSettings);
else raise Exception.CreateFmt('Writing of ini version "%s" not supported.',
[GetEnumName(TypeInfo(TVpIniVersion), ord(FIniVersionWrite))]);
iv104:
L := TVpIniStrings_v104.Create(@FFormatSettings);
iv105:
L := TVpIniStrings_v105.Create(@FFormatSettings);
else
raise Exception.CreateFmt('Writing of ini version "%s" not supported.',
[GetEnumName(TypeInfo(TVpIniVersion), ord(FIniVersionWrite))]);
end;
try
L.AddField('Complete', BoolToStr(ATask.Complete, strTRUE, strFALSE)); // 0
@ -778,7 +793,7 @@ begin
AEvent.AlarmSet := StrToBool(L.Extract(8));
AEvent.AlarmAdvance := StrToInt(L.Extract(9));
AEvent.AlarmAdvanceType := TVpAlarmAdvType(GetEnumValue(TypeInfo(TVpAlarmAdvType), L.Extract(10)));
AEvent.SnoozeTime := StrToTime(L[11]);
AEvent.SnoozeTime := StrToTime(L.Extract(11));
AEvent.RepeatCode := TVpRepeatType(GetEnumValue(TypeInfo(TVpRepeatType), L.Extract(12)));
if L[13] = '' then
AEvent.RepeatRangeEnd := 0 else