[Interest] QSettings stale lock file

Frank Hemer frank at hemer.org
Thu Feb 26 11:48:44 CET 2015


On Thursday 26 February 2015 08:43:11 Koehne Kai wrote:
> > -----Original Message-----
> > From: interest-bounces+kai.koehne=theqtcompany.com at qt-project.org
> > [mailto:interest-bounces+kai.koehne=theqtcompany.com at qt-project.org]
> > On Behalf Of Frank Hemer
> > Sent: Wednesday, February 25, 2015 5:24 PM
> > To: interest at qt-project.org
> > Subject: Re: [Interest] QSettings stale lock file
> > 
> > On Wednesday 25 February 2015 07:25:41 Thiago Macieira wrote:
> > > On Wednesday 25 February 2015 11:30:57 Frank Hemer wrote:
> > > > On a windows7 professional, I'm using QSettings for the local user -
> > > > the settings data is located on a roaming profile.
> > > > Now I experience stale lock files xxx.ini.lock (zero bytes) that
> > > > crash my application.
> > > > 
> > > > There is no other process running that could access the qsettings!
> > > > 
> > > > Can anyone shed some light on conditions that could cause this?
> > > 
> > > I think you're confusing cause with consequence. The lock files don't
> > > cause the crash; the crash is the cause for the files existing: the
> > > process stopped before the lock file could be removed.
> > 
> > well - I should have explained in more detail.
> > I was asking for the cause of the lock files to appear ... in many years I
> > have never seen these (well, prob. bec. they are created and removed in
> > some msecs). And looking at the code I expected to find some processID
> > written there, but the size was zero.
> 
> The reason is that QSettings since Qt 5.4 use QSaveFile to write, which in
> turn uses QLockFile.
> 
> See also the 5.4.0 change log:
> 
>    * [QTBUG-21739] The locking mechanism inside QSettings has changed
>      and is no longer compatible with the one of previous versions of
>      Qt. There might be corruption if two applications running different
>      versions of Qt are writing to the same config file at the same
>      time. You must also now have write permissions in the directory
>      containing the settings file in order to write settings.

Hmm - yes, that explains the appearance of lock files.
But it does not explain the zero size.

Frank



More information about the Interest mailing list