[PATCH] Revised patch for KUser
raabe at kde.org
Tue Jun 8 15:40:06 BST 2004
On Tuesday 08 June 2004 15:54, André Wöbbeking wrote:
> On Tuesday 08 June 2004 00:50, Oswald Buddenhagen wrote:
> > On Mon, Jun 07, 2004 at 09:40:00PM +0200, Jan Schäfer wrote:
> > > + QValueList<KUserGroup> groups() const;
> > > + QValueList<KUser> users() const;
> > now that is look at this, i'm not sure whether it is a good idea to
> > return lists of KUser[Group], as this may be excessively expensive.
> QValueList is implicit shared with copy on write semantic, isn't it?
It is, but it's a little dangerous:
for ( QValueList<KUser>::Iterator it = users().begin(); it != users().end();
That loop has totally random behaviour, since each call of "users()" yields a
different QValueList, so you're comparing "it" from one list with "end()"
from another (usually you get an endless loop). If you had returned the
valuelist by reference-to-const, that would not have happened (and for the
client, the difference is transparent).
More information about the kde-core-devel