[Development] Ref-counted quit

Olivier Goffart olivier at woboq.com
Mon Jan 2 14:25:17 CET 2012


On Monday 02 January 2012 10:51:31 Thiago Macieira wrote:	

> I don't see a need to expose the actual integer count of windows. 

It is not exposed.  ref() and deref() returns void.

> I really don't like "ref/deref" in QCoreApplication, as it doesn't make much
> sense.

It does:
 ref()  means "keep the application alive until i call deref()
And every ref() must be paired with a deref()
exactly like QSharedData ref.  that is i hink a concept that is very common 
and easy to understand.

After, it can be wrapped into more high level API in QtGui or something.

> It sounds like the QCoreApplication object will be deleted when the count
> reaches zero, which isn't true.

Yes, it is true.
 
> You say I am discarding valid use-cases. Maybe I am. Please propose a
> counter- alternative to what I have proposed. Start by not changing
> QCoreApplication's API -- a new class would be better.

a kind of  QKeepApplicationAlive object that would call ref() in its 
constructor, and deref() in its destructor?
Why not, but i like the simple ref/deref in QCoreApplication better.



I beleive the ref()/deref() API does the job well, and is very simple and 
easy.
And it has to be in QtCore, so it can be used by ui-less API (such as KJob)




More information about the Development mailing list