Прочитал статью про сериализацию, почти все получилось, кроме одного.
Есть класс
TGroupsList = class(TComponent)
...
published
property L: TGroupsColl read FL write SetL;
...
end;
И другой класс:
TComGenSettings = class(TComponent)
...
published
property GenresGroups: TGroupsList read FGenresGroups write SetGenresGroups;
...
end;
Так вот проблема, если сериализовать и потом читать TGroupsList, то все работает.
Файл получается примерно таким:
object TGroupsList
L = <
item
GroupName = 'g1'
Ids = <>
end
item
GroupName = 'ggg2'
Ids = <>
end>
TableName = 'Genres'
end
Чтобы сохранить класс TComGenSettings и в нем TGroupsList, нужно переопределить GetChildren:
begin
inherited GetChildren(Proc, Root);
if Root = Self then
if not GenresGroups.HasParent then
Proc(GenresGroups);
end;
Это я сделал, сохраняет на первый взгляд нормально:
object TComGenSettings
LastPreset = 'Def'
object TGroupsList
L = <
item
GroupName = 'kjhkh'
Ids = <>
end
item
GroupName = 'guu'
Ids = <>
end>
TableName = 'Genres'
end
end
Но при чтении почему-то получаем
---------------------------
Debugger Exception Notification
---------------------------
Project x.exe raised exception class EAccessViolation with message 'Access violation at address 00470786 in module 'PlGenPro.exe'. Read of address 00000000'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
В чем может быть дело?