PDA

View Full Version : Is it me or....



fullmetalcoder
14th June 2006, 15:50
For some reason I decided to refactor a piece of code of one of my projects this morning and the results I got sounded weird . After tracking errors I tried this piece of code :



QStringList val;

val << "subdirs";

qDebug("value : \'%s\'", val.at(0).toLatin1().data());

if ( val.at(0) != "subdirs" )
qFatal("Shit! what is QString doing?");



Guess the debug output I obtained!



value : 'subdirs'
Shit! what is QString doing?

:confused:

I was just wondering if there could be a rationnal reason for such a thing to happen... I tried a "make clean && qmake && make" => no changes!!! I'm about to reboot my computer re-"make clean && qmake && make", but, even it were to work again, I'd still be puzzled by this weird error...

jacek
14th June 2006, 16:08
It works OK on my system. Maybe the source file has some strange encoding?

fullmetalcoder
14th June 2006, 16:11
maybe... What's weird is that it just never happened before... maybe when i'll reboot my computer everything will be ok again... I really hope so! If it doesn't I'll try changing the encoding of the file or i'll check that QString::fromAscii works fine (it is said to be used in the comparison operator...)

fullmetalcoder
15th June 2006, 10:24
I fixed it! I forgot to mention that the way I filled the list was not that simple... And there lied the problem! :o

I parsed a QChar* by hand and the last word was always one char too long! And that char seemed to be some sort of unicode terminaison character (it looked like a sucribe 'x') and was not conserved by toLatin1() thus it didn't appeared in the debug output, until I used QMessageBox::warning() instead of qDebug()...