wxFileConfig overwrite prevention strategy?

Carl Godkin cgodkin at gmail.com
Mon Sep 3 12:16:37 PDT 2007


Hi,

I'm using wxConfigBase in wxGTK 2.8.0 to save a few configuration parameters
from our package.  Our package is made up of several programs, and I am
apparently
having a problem with wxFileConfig overwriting my configuration file when it
is
used by more than one application.

To be concrete:

If I have a package called "Package," wxConfigBase on Linux will write the
config file
entries to a file in my home directory called "~/.Package."

Different programs in this package all use this single file, putting
"[ApplicationA]"
and "[ApplicationB]" and so on into the ~/.Package file as separators.

Suppose I start ApplicationA first and modify its configuration.

Then I start ApplicationB, modify its configuration, and then exit.  Closing
ApplicationB
will flush the changes to disk, so that ~/.Package is updated.

Then if ApplicationA exits after that, it will flush its own changes to
~/.Package which
will apparently overwrite ApplicationB's changes since I don't think A
checks if
~/.Package was updated before writing.

I hope that's not too confusing.

What can I do to prevent the applications in my package from doing this?

One strategy that should work would be to follow each wxConfigBase::Write()
call
(or group of calls) with wxConfigBase::Flush() so that the destructor does
not write
the file.  But this seems like only a partial solution because I really want
wxFileConfig::Get() to check if the file is updated and reload the file
before
returning an updated pointer.  Or is there a way to do this that I am
missing?

(Of course this is not any sort of problem with the Windows registry
implementation
we use on Windows.)

Thanks for any advice,

carl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wx-users/attachments/20070903/fa7=
e3571/attachment.htm


More information about the wx-users mailing list