[Qt-interest] QStringList copy constructor doing something funny?

Thiago Macieira thiago at kde.org
Fri Sep 16 13:39:00 CEST 2011


On Friday, 16 de September de 2011 11:05:06 Jaco Naude wrote:
> Hi
> 
> I've run into a weird problem today.
> 
> The following piece of code crashes:
> 
> QStringList arguments;
> // Some population of arguments.
> 
> if (arguments.count() == 3) {
>     if (arguments.at(1) == "-p") {
>         QFileInfo fi(arguments.at(2)); // Crash here
>         // Do some stuff with fi.
>     }
> }
> 
> But the following does not crash:
> 
> if (arguments.count() == 3) {
>     if (arguments.at(1) == "-p") {
>         QString file_name = arguments.at(2);  // Does not crash here
>         QFileInfo fi(file_name );
>         // Do some stuff with fi.
>     }
> }
> 
> Honestly, I don't get it.
> Any experts out there understand it?

Experts need a backtrace, a valgrind trace and a testcase.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110916/6785ac8b/attachment.bin 


More information about the Qt-interest-old mailing list