Bug 190464 - QByteArray isn't saved in KConfig
Summary: QByteArray isn't saved in KConfig
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: kdecore (show other bugs)
Version: 4.2.2
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-23 20:46 UTC by Karai Csaba
Modified: 2009-05-02 17:37 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Karai Csaba 2009-04-23 20:46:31 UTC
Version:            (using KDE 4.2.2)
OS:                Linux
Installed from:    SuSE RPMs

Hi,

I'm a developer of Krusader, and get into a bug related to saving QByteArray in KConfig (the problem is, that KConfig doesn't save QByteArray if it already exists in the config file).

This code helps to reproduce the bug:

Code:
=================

#include <kconfig.h>
#include <kconfiggroup.h>
#include <QtCore/qbytearray.h>
#include <stdio.h>
#include <qapplication.h>

int main( int argc, char **argv )
{
  QApplication app(argc,argv,false);
  KConfig myConfig( "myconfig.rc" );
  KConfigGroup group( &myConfig, "MySection" );

  // 220 chars
  char * mychars =  "\x00\x00\x00\xff\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00"
                    "\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
                    "\x09\xa8\x01\x00\x00\x00\x04\x00\x00\x00\x08\x00\x00\x00\x64\x00"
                    "\x00\x00\x07\x00\x00\x00\x64\x00\x00\x00\x05\x00\x00\x00\x64\x00"
                    "\x00\x00\x03\x00\x00\x00\x64\x00\x00\x01\xcd\x00\x00\x00\x09\x01"
                    "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x64"
                    "\xff\xff\xff\xff\x00\x00\x00\x81\x00\x00\x00\x00\x00\x00\x00\x09"
                    "\x00\x00\x00\xcf\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x30"
                    "\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x46\x00\x00\x00\x01"
                    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00"
                    "\x00\x00\x00\x6c\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
                    "\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x1c\x00\x00\x00\x01"
                    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00"
                    "\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00";

  QByteArray defArr( mychars, 220 );

  printf( "Loading QByteArray...\n" );
  QByteArray myByteArr = group.readEntry( "MyByteArr", defArr );
  printf( "Char read: %d\n", (char)myByteArr[ 9 ] );
  myByteArr[ 9 ] = (char)(myByteArr[ 9 ] + 1);
  printf( "After increment: %d\n", (char)myByteArr[ 9 ] );
  group.writeEntry( "MyByteArr", myByteArr );
  printf( "Writing QByteArray...\n" );
}


Output:
==============================

Char read: 0
After increment: 1
Writing QByteArray...
ckarai@linux-mr5o:~/krusader_kde4_test> krusader/krusader
Loading QByteArray...
Char read: 1
After increment: 2
Writing QByteArray...
ckarai@linux-mr5o:~/krusader_kde4_test> krusader/krusader
Loading QByteArray...
Char read: 1
After increment: 2
Writing QByteArray...
ckarai@linux-mr5o:~/krusader_kde4_test> krusader/krusader
Loading QByteArray...
Char read: 1
After increment: 2


Summary:
===============

At the first time QByteArray is saved properly, but after it isn't.
Comment 1 Oswald Buddenhagen 2009-05-02 17:37:04 UTC
SVN commit 962585 by ossi:

don't drop changes of binary data

somebody give me a brown paper bag - the not-actually-modified check
used strcmp for the byte array comparison ...

BUG: 190464


 M  +1 -1      config/kconfigdata.h  
 M  +14 -0     tests/kconfigtest.cpp  
 M  +1 -0      tests/kconfigtest.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=962585