Firstly, the question is about TRegistry and not TRegIniFile. On a *nix platform TRegistry is implemented using TXMLRegistry and not TRegIniFile.

You should only have a single instance of a TXMLRegistry in any one program no matter how many times you create a TRegistry object - they all point to the same instance. From a quick check of the code, it looks like the problem identified in the bug reportĀ  is fairly obvious - the current key state is held in TXMLRegistry rather than TRegistry. The fix should be to hold the current key state in TRegistry and call TXMLRegistry.SetKey before every get or put call on TXMLRegistry (from TRegistry).

TRegistry is a very useful way of saving dynamic configuration data (e.g. mainform co-ordinates) in order to preserve them from one program session to another - and to do so in a cross-platform manner. IMHO. it would be a significant loss if it was to be deprecated. I use it all the time.

As to the filename issue: the xml file location is determined from the Vendor Name and application name and relative to $HOME/.config - is that really a problem?

TXMLRegistry writes are normally flushed to disk after every write. Two program instances using the same registry keys can get in each other's way with one over-writing the other's updates - but then that is also true of .conf and .ini files - and even the Windows registry.

On 04/05/2020 08:29, Bart via lazarus wrote:
On Mon, May 4, 2020 at 12:41 AM Bo Berglund via lazarus
<lazarus@lists.lazarus-ide.org> wrote:
structure:
HKLM\SOFTWARE\Companyname\Applicationname\Server\(named values)
HKLM\SOFTWARE\Companyname\Applicationname\Configuration\(named values)
The *nix way is to use .conf files (basically ini-files) for that.
IIRC you have no control over where the xml file (with the registry
keys) is placed.
There are some issues with the xml implementation of the registry.
Most important: TRegIniFile is completely broken and as of 3.2
deprecated on non-windows platforms.
Also, when you have 2 keys opened at the same time, reading/writing
may go to/from the wrong key:
https://bugs.freepascal.org/view.php?id=36842

For a cross-platform application I wouldn't use TRegistry myself.

Bart
--
_______________________________________________
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus

Reply via email to