[Qt-interest] QStringList copy constructor doing something funny?
Bo Thorsen
bo at fioniasoftware.dk
Fri Sep 16 13:23:06 CEST 2011
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
More information about the Qt-interest-old
mailing list