[Qt-interest] Qt memory management.

Andre Somers andre at familiesomers.nl
Wed Aug 18 13:27:49 CEST 2010


  Op 18-8-2010 13:10, Ramesh schreef:
> Fine andres..
> I do agree.. but what about this case.
>
> QString a = "foo"; // "QStringPrivate" has a refcount of 1
> QString b = a;// Shallow copy of QStringPrivate, that now has a refcount of
> 2
> a = "chock" // in this case?
>
> If we change the value of a, then what about b?
>
>   b should point to "foo" right. So what happens in this case, I guess
> Deepcopy occurs right?
Good guess :-)
A deep copy occurs on write. No matter who instantiates that write.

André



More information about the Qt-interest-old mailing list