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

Jaco Naude naude.jaco at gmail.com
Fri Sep 16 13:32:39 CEST 2011


Well, there is not any other code. I break the debugger on the line where it
breaks and I can see all three items in the QStringList. When I click "Step
Over" it crashes, and if I "Step Into" it also crashes without any
additional info.


On Fri, Sep 16, 2011 at 11:23 AM, Bo Thorsen <bo at fioniasoftware.dk> wrote:

> Den 16-09-2011 13:18, Mandeep Sandhu skrev:
> >>          QFileInfo fi(arguments.at(2)); // Crash here
> >
> > This is because of an 'automatic variable' being used here. The return
> > value of the function (QList::at()) is stored in an automatic variable
> > (created by the complier) who's scope is this line of code alone. This
> > variable does not exist after the said stmt.
> >
> > However, when you storing it in a separate var 'file_name', it
> > persists till the encapsulating if block's scope.
>
> Sorry, but this is pure nonsense. The QFileInfo constructor will copy
> the string and store it locally. The problem is somewhere else in the code.
>
> Bo Thorsen,
> Fionia Software.
>
> --
>
> Expert Qt and C++ developer for hire
> Contact me if you need expert Qt help
> http://www.fioniasoftware.dk
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110916/bf792cae/attachment.html 


More information about the Qt-interest-old mailing list