[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: KConfigGroup read/write bug for QByteArray
From:       "Andreas Hartmetz" <ahartmetz () gmail ! com>
Date:       2007-09-17 11:07:54
Message-ID: f3642e6b0709170407p5b4651aah8939f3c5212c2d17 () mail ! gmail ! com
[Download RAW message or body]

2007/9/17, David Jarvie <lists@astrojar.org.uk>:
> On Sunday 16 September 2007 14:41:28 Matt Rogers wrote:
> > On Sunday 16 September 2007 07:41, David Jarvie wrote:
> > > Using KConfigGroup::writeEntry() to write a QByteArray and then
> > > KConfigGroup::readEntry() to read it back in again can result in a value
> > > which is different from the original value, because the value written to
> > > the config file is converted to UTF8 when it is read back, so that all
> > > byte values >= 0x7F are changed to multi-byte values.
> > >
> > > If this is the desired behaviour (which I doubt), it's difficult to
> > > convert back from UTF8 since calling QString::fromUtf8 truncates the
> > > value as soon as it encounters a null byte. In data arrays, null bytes
> > > are common.
> >
> > Can you provide a patch? Then we can discuss your proposal based on the
> > technical merits of it rather than just sitting in our chairs wondering to
> > ourselves how it would actually work and whether or not we'd like it.
>
> It turns out that the bug actually lies in KConfigGroup::writeEntry(), and
> that all that is required is for a QByteArray not to be converted to UTF8
> before being written. I attach a patch to fix it, and to add a test case to
> the unit test.
>
Very good, thanks. Not converting will give us *more* speed, not less :)
KConfig, by the way, is very easy to write unit tests for and it also
needs them because it's complicated internally. So keep adding them in
case of problems!

> --
> David Jarvie.
> KAlarm author and maintainer.
> http://www.astrojar.org.uk/kalarm
>
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic