[Qt-interest] "%" characters in QStrings create havoc

KC Jones kc at asperasoft.com
Fri Feb 26 21:30:02 CET 2010


Thanks for all the suggestions.  It may take me a while to absorb them.  I
had never noticed the multi-argument variantions of .arg().  Good to know. I
think that will solve my problem.

My crash was unrelated.  No surprise there. I was calling an object method
through a null pointer, then accessing a member variable of the null
object.  I'm surprised that the method call didn't crash immediately -- I
guess the fact that the method was declared as a slot means it exists in the
scope of the static metaObject, and can therefor be called through a null
pointer???  When the debugger told me that the class member variable was
'out of scope' I looked up the stack and figured it out.

> QString clause = QString(" WHERE (name LIKE '%1') OR (email LIKE '%2') ")
> >                     .arg(exp1).arg(exp2);
>
> As far as I can tell, QString::arg() is not supposed to crash, no
> matter what you throw at it. At worst you'll have a qWarning saying
> "QString::arg: Argument missing: ... ".
>
> So, unless there is a bug in QString::arg (which I doubt), I'd say the
> crash is coming from somewhere else (memory corruption ?).
>
> --
> Julien Cugnière
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100226/413e8e95/attachment.html 


More information about the Qt-interest-old mailing list