[Interest] Certain QTextCodecs causing crashes on Linux

Scott Aron Bloom scott.bloom at onshorecs.com
Wed Jul 31 21:24:28 CEST 2013


The system local is definitely part of the problem....

Should I instead just set the CString and Tr codecs?  I remember going through this previously (~6 months ago) and locale worked... but I don't remember what I tried

Essentially Im doing a 

QByteArray data = fi.readLine()
QString contents = QString::fromLocal8Bit( currData )
setPlainText( contents )

Would the other setCodec functions be better ?
Scott




-----Original Message-----
From: interest-bounces+scott.bloom=onshorecs.com at qt-project.org [mailto:interest-bounces+scott.bloom=onshorecs.com at qt-project.org] On Behalf Of Thiago Macieira
Sent: Wednesday, July 31, 2013 11:55 AM
To: interest at qt-project.org
Subject: Re: [Interest] Certain QTextCodecs causing crashes on Linux

On quarta-feira, 31 de julho de 2013 18:21:42, Scott Aron Bloom wrote:
> As to the size of the codec.. Is there a way to tell the size?

Hmm... You can feed it an 'a' and see how many bytes come out. Actually, verify that the output is exactly one byte 0x61. That way, you'll also prevent someone from setting EBCDIC or other funky 8-bit codecs.

> The reason I ask, this functionality in the tool came from the 
> applications need to allow the customer to set a Chinese codec, so 
> that the customers mixed language text file could be read in.

Are you sure you need to set the *locale* codec for that? Please note that it affects filenames on disk too (on Unix) and just about every kind of 8-bit system API.

> Hrere is the traceback..
> 
> #0  0x0000003edaa328a5 in raise () from /lib64/libc.so.6
> #1  0x0000003edaa34085 in abort () from /lib64/libc.so.6
> #2  0x0000003edc25ea0f in g_assertion_message () from
> /lib64/libglib-2.0.so.0
> #3  0x0000003edc25efb0 in g_assertion_message_expr
> () from /lib64/libglib-2.0.so.0
> #4  0x0000003ee522562e in ?? () from
> /usr/lib64/libgconf-2.so.4
> #5  0x0000003ee5227c38 in ?? () from /usr/lib64/libgconf-2.so.4
> #6  0x0000003ee522906d in ?? () from /usr/lib64/libgconf-2.so.4
> #7  0x0000003ee5229663 in gconf_client_get_bool () from
> /usr/lib64/libgconf-2.so.4
> #8  0x00007ffff78b571c in ?? () from
> /usr/local/Trolltech/Qt-4.7.4/lib/libQtGui.so.4
> #9  0x00007ffff789fd8a in
> QGtkStyle::styleHint(QStyle::StyleHint, QStyleOption const*, QWidget 
> const*, QStyleHintReturn*) const () from
> /usr/local/Trolltech/Qt-4.7.4/lib/libQtGui.so.4

Gtk style... I see exactly one use of gconf_client_get_bool:

styles/qgtkstyle_p.cpp:        bool result = gconf_client_get_bool(client, 
qPrintable(key), &err);

Remember that qPrintable is .toLocal8Bit().constData(). That means we've just passed an UTF-32 string to gconf. I bet that's why it choked.

--
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center



More information about the Interest mailing list