View Issue Details

IDProjectCategoryView StatusLast Update
0003570JEDI VCL00 JVCL Componentspublic2006-03-10 02:48
ReporterKiriakosAssigned ToAHUser 
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in Version3.30 
Summary0003570: AppStorage bug when reading nested object lists in v3.2
DescriptionThe problem is in the following function. TargetStore.FCurrentInstanceCreateEvent is set to nil on exit which means that if this call made from an outer ReadObjectList call when the outer call will crash making a call to function which is set to nil.

function TJvCustomAppStorage.ReadObjectList(const Path: string; List: TList;
  ItemCreator: TJvAppStorageObjectListItemCreateEvent;
  const ClearFirst: Boolean = True; const ItemName: string = cItem): Integer;
var
  TargetStore: TJvCustomAppStorage;
  TargetPath: string;
begin
  if not ListStored(Path) and StorageOptions.DefaultIfValueNotExists then
    Result := List.Count
  else
  begin
    if ClearFirst then
      List.Clear;
    ResolvePath(Path + cSubStorePath, TargetStore, TargetPath); // Only needed for assigning the event
    TargetStore.FCurrentInstanceCreateEvent := ItemCreator;
    Result := ReadList(Path, List, ReadObjectListItem, ItemName);
    TargetStore.FCurrentInstanceCreateEvent := nil;
  end;
end;
Additional InformationSolution.
Change the above method to:

function TJvCustomAppStorage.ReadObjectList(const Path: string; List: TList;
  ItemCreator: TJvAppStorageObjectListItemCreateEvent;
  const ClearFirst: Boolean = True; const ItemName: string = cItem): Integer;
var
  FOldInstanceCreateEvent: TJvAppStorageObjectListItemCreateEvent;
  TargetStore: TJvCustomAppStorage;
  TargetPath: string;
begin
  if not ListStored(Path) and StorageOptions.DefaultIfValueNotExists then
    Result := List.Count
  else
  begin
    if ClearFirst then
      List.Clear;
    ResolvePath(Path + cSubStorePath, TargetStore, TargetPath); // Only needed for assigning the event
    FOldInstanceCreateEvent := TargetStore.FCurrentInstanceCreateEvent;
    TargetStore.FCurrentInstanceCreateEvent := ItemCreator;
    Result := ReadList(Path, List, ReadObjectListItem, ItemName);
    TargetStore.FCurrentInstanceCreateEvent := FOldInstanceCreateEvent;
  end;
end;
TagsNo tags attached.

Activities

AHUser

2006-03-10 02:48

developer   ~0008643

Fixed in CVS.

Issue History

Date Modified Username Field Change
2006-03-09 15:05 Kiriakos New Issue
2006-03-10 02:48 AHUser Status new => resolved
2006-03-10 02:48 AHUser Resolution open => fixed
2006-03-10 02:48 AHUser Assigned To => AHUser
2006-03-10 02:48 AHUser Note Added: 0008643