Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0003728 [JEDI VCL] 00 JVCL Components feature always 2006-05-26 02:20 2006-06-08 03:44
Reporter Kiriakos View Status public  
Assigned To obones
Priority normal Resolution fixed  
Status resolved   Product Version 3.20
Summary 0003728: JvAppStrorage could avoid saving properties with default values
Description JvAppStrorage could avoid saving properties with default values as Delphi does when it saves forms. This could save space and loading/saving time.
Additional Information
Tags No tags attached.
Attached Files txt file icon JvAppStoragepatch.txt [^] (2,586 bytes) 2006-06-05 05:00
txt file icon JvAppStoragepatch2.txt [^] (3,276 bytes) 2006-06-05 15:35

- Relationships

-  Notes
(0009377)
obones (administrator)
2006-06-05 01:48

How do you get the default value for a property ?
(0009380)
Kiriakos (reporter)
2006-06-05 05:01

See the attached file for an implementation of this feature and the answer to your question. It is a diff file against the current SVN version of JvAppStorage.pas
(0009385)
obones (administrator)
2006-06-05 08:01

Nice patch here.
I have some question:
Why is the default value for Int64 forced to be 0? Delphi's compiler accepts a Int64 property with a default value, isn't there a way to retrieve it?
Is there a way to retrieve the value returned by a "stored" property marker? You know, the value returned by the function given just after the "stored" keyword.

I tested the Int64 part with Delphi 7 and 2006.
Thanks a lot for the patch, it's good to go, just curious about the two points above.
(0009389)
Kiriakos (reporter)
2006-06-05 15:43

New patch replacing old one uploaded.
Improvements:
- Do not store read-only or write-only properties
- Do not store properties for which IsStoredProp returns false
The above mimic standard VCL behaviour

Regarding Int64 properties, I am not sure Delphi respects a default value different than 0 (which should be considered a bug). Look at the code of IsDefaultPropertyValue in Classes.pas to see for yourself. If it does I am not able to see how.
(0009390)
Kiriakos (reporter)
2006-06-05 15:44

New patch replacing old one uploaded.
Improvements:
- Do not store read-only or write-only properties
- Do not store properties for which IsStoredProp returns false
The above mimic standard VCL behaviour

Regarding Int64 properties, I am not sure Delphi respects a default value different than 0 (which should be considered a bug). Look at the code of IsDefaultPropertyValue in Classes.pas to see for yourself. If it does I am not able to see how.
(0009391)
jfudickar (developer)
2006-06-06 02:24

My comment: I like the idea, but this should be an optional parameter and the default should be "saving the default values".
(0009400)
obones (administrator)
2006-06-07 03:07

This is an optional parameter, so that is Fine.
However, I have one question: Why not simply call IsDefaultPropertyValue?
Something like that:

if not StorageOptions.StoreDefaultValues and
   (not Assigned(P^.GetProc) or not Assigned(P^.SetProc) or
    not IsStoredProp(PersObj, P) or IsDefaultPropertyValue(PersObj, P, nil)) then
  Exit;

I know this makes the new property also apply to Read/Write only properties and "stored" keyword, but that looks easier to me.
(0009411)
Kiriakos (reporter)
2006-06-07 13:38

This was my original thought. However IsDefaultPropertyValue has features specific to storing components in VCL. For example it does not not store child component properties unless they are marked as SubComponents. See below:

Result := True;
  if (PropInfo^.GetProc <> nil) and
     ((PropInfo^.SetProc <> nil) or
     ((PropInfo^.PropType^.Kind = tkClass) and
      (TObject(GetOrdProp(Instance, PropInfo)) is TComponent) and
      (csSubComponent in TComponent(GetOrdProp(Instance, PropInfo)).ComponentStyle))) then
(0009413)
obones (administrator)
2006-06-08 01:21

Well, not exactly. The second part is an "or", hence it will test for anything, even tkClass, when there is a setter.
Anyway, just to be on the safe side, I removed it from the initial condition and added it to every element of the case except tkClass.
This is now in SVN, let me know if that's ok with you so that I can close this issue.
(0009441)
jfudickar (developer)
2006-06-08 03:32

Hi Olivier,

i've looked at your changes.

For backward compatibility, the default value of the property should be true.

Or we decide to ignore the backward compatibility.

Greetings
Jens
(0009443)
obones (administrator)
2006-06-08 03:35

Yes, you are right, I changed this.
(0009444)
Kiriakos (reporter)
2006-06-08 03:37

The changes are fine.
(0009448)
obones (administrator)
2006-06-08 03:44

This is then marked as fixed. Thanks to everyone involved here.

- Issue History
Date Modified Username Field Change
2006-05-26 02:20 Kiriakos New Issue
2006-06-05 01:48 obones Note Added: 0009377
2006-06-05 01:48 obones Status new => feedback
2006-06-05 05:00 Kiriakos File Added: JvAppStoragepatch.txt
2006-06-05 05:01 Kiriakos Note Added: 0009380
2006-06-05 08:01 obones Note Added: 0009385
2006-06-05 15:35 Kiriakos File Added: JvAppStoragepatch2.txt
2006-06-05 15:43 Kiriakos Note Added: 0009389
2006-06-05 15:44 Kiriakos Note Added: 0009390
2006-06-06 02:24 jfudickar Note Added: 0009391
2006-06-07 03:07 obones Note Added: 0009400
2006-06-07 13:38 Kiriakos Note Added: 0009411
2006-06-08 01:21 obones Note Added: 0009413
2006-06-08 03:32 jfudickar Note Added: 0009441
2006-06-08 03:35 obones Note Added: 0009443
2006-06-08 03:37 Kiriakos Note Added: 0009444
2006-06-08 03:44 obones Status feedback => resolved
2006-06-08 03:44 obones Resolution open => fixed
2006-06-08 03:44 obones Assigned To => obones
2006-06-08 03:44 obones Note Added: 0009448


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker