View Issue Details

IDProjectCategoryView StatusLast Update
0001545JEDI VCL00 JVCL Componentspublic2004-03-31 06:07
ReporterFlyingAvatarAssigned Touser72 
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0001545: jvAppIniFileStorage ignores DefaultSection on StoredProps
DescriptionWhen using a jvAppIniFileStorage to store the columns property of a ListView, previous versions of JVCL would store this to the INI section "[DefaultSection.ListView1_Columns]".

When migrating to version JVCL 3, I've experienced a different behavior, which seems incorrect. Even though DefaultSection is set and the position information is stored under it, stored properties were stored as "[.ListView_Columns]" in the INI without the default section before the name.

Also, I assume that preserving the INI file in memory is intentional, but I would prefer that there be a property named something like "CacheINI" to disable this behavior. I currently make changes to the INI separate from jvAppIniFileStorage and these changes are "undone" by jvAppIniFileStorage when the form is closed.
TagsNo tags attached.

Activities

user72

2004-03-30 13:24

  ~0003525

Try changing the following in JvAppIniStorage.pas:

function TJvCustomAppIniStorage.ReadValue(const Section, Key: string): string;
var ASection:string;
begin
  if IniFile <> nil then
  begin
    if Section = '' then
      ASection := DefaultSection
    else
      ASection := Section;
    if ASection = '' then
      raise EJVCLAppStorageError.Create(RsEReadValueFailed);
    Result := IniFile.ReadString(ASection, Key, '');
  end
  else
    Result := '';
end;

procedure TJvCustomAppIniStorage.WriteValue(const Section, Key, Value: string);
var ASection:string;
begin
  if IniFile <> nil then
  begin
    if Section = '' then
      ASection := DefaultSection
    else
      ASection := Section;
    if ASection = '' then
      raise EJVCLAppStorageError.Create(RsEWriteValueFailed);
    IniFile.WriteString(DefaultSection, Key, Value);
    if AutoFlush and not IsUpdating then Flush;
  end;
end;

> Also, I assume that preserving the INI file in memory is intentional [...]
There are solutions to this problem. See the discussion in the newsgroups

marcelb

2004-03-31 02:26

manager   ~0003535

Peter, this wouldn't help, since the Section will be '.ListView_Columns'. Technically we could alter the methods to prepend DefaultSection is the Section starts with a '.'. This would remove the possibility of storing to any path starting with a '.' but I doubt that would be a problem.

So changing to this (untested) might be better:

function TJvCustomAppIniStorage.ReadValue(const Section, Key: string): string;
var ASection:string;
begin
  if IniFile <> nil then
  begin
    if (Section = '') or (Section[1] = '.') then
      ASection := DefaultSection
    else
      ASection := Section;
    if (ASection = '') or (ASection[1] = '.') then
      raise EJVCLAppStorageError.Create(RsEReadValueFailed);
    Result := IniFile.ReadString(ASection, Key, '');
  end
  else
    Result := '';
end;

procedure TJvCustomAppIniStorage.WriteValue(const Section, Key, Value: string);
var ASection:string;
begin
  if IniFile <> nil then
  begin
    if (Section = '') or (Section[1] = '.') then
      ASection := DefaultSection
    else
      ASection := Section;
    if (ASection = '') or (ASection[1] = '.') then
      raise EJVCLAppStorageError.Create(RsEWriteValueFailed);
    IniFile.WriteString(DefaultSection, Key, Value);
    if AutoFlush and not IsUpdating then Flush;
  end;
end;

user72

2004-03-31 03:14

  ~0003537

Shouldn't that be:

    if (Section = '') or (Section[1] = '.') then
      ASection := DefaultSection + Section
    else
      ASection := Section;

Since otherwise you would loose anything after the dot?

marcelb

2004-03-31 03:21

manager   ~0003538

Correct. A little too hasty posting the change <g>

user72

2004-03-31 06:07

  ~0003539

Fixed in CVS

Issue History

Date Modified Username Field Change
2004-03-29 09:37 FlyingAvatar New Issue
2004-03-30 13:24 user72 Note Added: 0003525
2004-03-30 13:24 user72 Status new => assigned
2004-03-30 13:24 user72 Assigned To => user72
2004-03-30 13:24 user72 Status assigned => feedback
2004-03-31 02:26 marcelb Note Added: 0003535
2004-03-31 03:14 user72 Note Added: 0003537
2004-03-31 03:21 marcelb Note Added: 0003538
2004-03-31 06:07 user72 Status feedback => resolved
2004-03-31 06:07 user72 Resolution open => fixed
2004-03-31 06:07 user72 Note Added: 0003539