[prev in list] [next in list] [prev in thread] [next in thread] 

List:       amarok-devel
Subject:    Re: [amarok] /: AudioCdCollection: don't create a reference out of temporary var (crashfix)
From:       Kevin Funk <krf () gmx ! de>
Date:       2012-05-08 10:14:53
Message-ID: 3492394.qsvbBOtB9y () kerberos
[Download RAW message or body]

On Tuesday 08 May 2012, 09:10, Bart Cerneels wrote:
> The temporary QString returned by url() should remain valid until the
> end of the local scope. At least that is what I think, but it's a
> tricky one. I hope I'm proven wrong by the bug being fixed.
> 
> On Mon, May 7, 2012 at 11:42 PM, Matěj Laitl <matej@laitl.cz> wrote:
> (snip)

This is indeed a tricky one, interesting.

But Matej is right, the url.url() creates a temporary (rvalue) which is 
destroyed right after the end of the expression that uses it (so *not* at the 
end of the local scope).

The interesting thing is that there is no compiler warning about this.
In any case I'd recommend doing the QString::remove() after a new line to make 
this even more clear.

Relevant: http://stackoverflow.com/questions/584824/guaranteed-lifetime-of-
temporary-in-c

Greets

-- 
Kevin Funk
_______________________________________________
Amarok-devel mailing list
Amarok-devel@kde.org
https://mail.kde.org/mailman/listinfo/amarok-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic