Optimize space for the QEventLoopQuitLocker.

Use a union and a type enum instead of three pointers.

Change-Id: I02b11733a4f2e95099064fa9325497d4e04ac615
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
This commit is contained in:
Stephen Kelly 2012-02-23 12:59:21 +01:00 committed by Qt by Nokia
parent beab403d9f
commit 184c9e346e

View File

@ -322,37 +322,51 @@ class QEventLoopLockerPrivate
{ {
public: public:
explicit QEventLoopLockerPrivate(QEventLoopPrivate *loop) explicit QEventLoopLockerPrivate(QEventLoopPrivate *loop)
: loop(loop), thread(0), app(0) : loop(loop), type(EventLoop)
{ {
loop->ref(); loop->ref();
} }
explicit QEventLoopLockerPrivate(QThreadPrivate *thread) explicit QEventLoopLockerPrivate(QThreadPrivate *thread)
: loop(0), thread(thread), app(0) : thread(thread), type(Thread)
{ {
thread->ref(); thread->ref();
} }
explicit QEventLoopLockerPrivate(QCoreApplicationPrivate *app) explicit QEventLoopLockerPrivate(QCoreApplicationPrivate *app)
: loop(0), thread(0), app(app) : app(app), type(Application)
{ {
app->ref(); app->ref();
} }
~QEventLoopLockerPrivate() ~QEventLoopLockerPrivate()
{ {
if (loop) switch (type)
{
case EventLoop:
loop->deref(); loop->deref();
else if (thread) break;
case Thread:
thread->deref(); thread->deref();
else break;
default:
app->deref(); app->deref();
break;
}
} }
private: private:
QEventLoopPrivate *loop; union {
QThreadPrivate *thread; QEventLoopPrivate * loop;
QCoreApplicationPrivate *app; QThreadPrivate * thread;
QCoreApplicationPrivate * app;
};
enum Type {
EventLoop,
Thread,
Application
};
const Type type;
}; };
/*! /*!