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

List:       kde-devel
Subject:    Re: how to keep the eventloop from doing magic things, sigh
From:       Thiago Macieira <thiago () kde ! org>
Date:       2009-04-15 17:54:15
Message-ID: 200904151954.15406.thiago () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


Em Terça-feira 14 Abril 2009, às 12:50:49, Arnold Krille escreveu:
> On Tuesday 14 April 2009 12:14:49 David Jarvie wrote:
> > On Tuesday 14 April 2009 7:03 am, Thiago Macieira wrote:
> > > Note that a thread is not started in the QThread constructor, so all
> > > objects created in the constructor are running in the parent thread.
> > > This is an important fact and many, many developers are bitten by this
> > > fact.
> >
> > I had a quick scan through the Qt thread documentation, and couldn't find
> > any mention of this. So perhaps it's not surprising that people often
> > fall into this trap. The documentation ought to be augmented.
>
> What about this:
> http://doc.trolltech.com/4.5/threads.html#qobject-reentrancy
>
> And the docs of QThread clearly state that _only_ run() is executed in the
> new thread...
>
> This is actually another case where the documentation is there, you just
> have to read (and maybe understand it).

It's the kind of thing that it's there if you realise it, but it's not 
obvious. It's a caveat.

It's like this:
	QString::toLatin1() returns a QByteArray
	QByteArray owns the data
	QByteArray::constData() returns a pointer to that data

People usually know those three separate facts. But they fail to put the three 
together when writing the code:

	const char *ptr = str.toLatin1().constData();
	printf("%s", ptr);

It's a caveat too: you're actually using a dangling pointer in the printf 
line. It's not documented, because all the information is there if you look 
for it. But it's not obvious at first glance.

Both are examples of things that need to bite you once. After that, you'll 
remember.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Software
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

["signature.asc" (application/pgp-signature)]

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


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

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