From 78125ea2f051107b84fdc0354acdedb7885308ee Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 6 Dec 2012 16:47:27 -0600 Subject: Add real threading support, including per-thread event loops, to QThread --- src/tools/qmutex_unix.cpp | 1 - src/tools/qthreadinstance_p.h | 6 ++++++ src/tools/qucom.cpp | 24 ++++++++++++++++++++++++ src/tools/qucom_p.h | 4 +++- 4 files changed, 33 insertions(+), 2 deletions(-) (limited to 'src/tools') diff --git a/src/tools/qmutex_unix.cpp b/src/tools/qmutex_unix.cpp index 7f14e6a..fe60ac3 100644 --- a/src/tools/qmutex_unix.cpp +++ b/src/tools/qmutex_unix.cpp @@ -74,7 +74,6 @@ typedef pthread_mutex_t Q_MUTEX_T; #include #include - // Private class declarations class QRealMutexPrivate : public QMutexPrivate { diff --git a/src/tools/qthreadinstance_p.h b/src/tools/qthreadinstance_p.h index 72611b1..7580b25 100644 --- a/src/tools/qthreadinstance_p.h +++ b/src/tools/qthreadinstance_p.h @@ -62,8 +62,12 @@ #include #endif +class QThread; +class QEventLoop; + class QThreadInstance { public: + static void setCurrentThread(QThread *thread); static QThreadInstance *current(); void init(unsigned int stackSize); @@ -95,6 +99,8 @@ public: static unsigned int __stdcall start( void * ); static void finish( QThreadInstance * ); #endif // Q_OS_WIN32 + + QEventLoop* eventLoop; }; #endif // QT_THREAD_SUPPORT diff --git a/src/tools/qucom.cpp b/src/tools/qucom.cpp index f210318..c48e166 100644 --- a/src/tools/qucom.cpp +++ b/src/tools/qucom.cpp @@ -39,6 +39,9 @@ **********************************************************************/ #include "qucom_p.h" +#include "qucomextra_p.h" + +#include "qvariant.h" // Standard types @@ -545,3 +548,24 @@ void QUType_QString::clear( QUObject *o ) delete (QString*)o->payload.ptr; o->payload.ptr = 0; } + +QUObject* QUObject::deepCopy(QUObject* newLocation) { + QUObject* ret; + if (newLocation) { + ret = new(newLocation) QUObject(*this); + } + else { + ret = new QUObject(*this); + } + // Any type that has a clear() method must be copied here! + if (*(type->uuid()) == TID_QUType_charstar) { + static_QUType_charstar.set( ret, (const char *)static_QUType_charstar.get(this), true ); + } + if (*(type->uuid()) == TID_QUType_QString) { + static_QUType_QString.set( ret, (QString)static_QUType_QString.get(this) ); + } + if (*(type->uuid()) == TID_QUType_QVariant) { + static_QUType_QVariant.set( ret, (QVariant)static_QUType_QVariant.get(this) ); + } + return ret; +} diff --git a/src/tools/qucom_p.h b/src/tools/qucom_p.h index 6410ceb..3ade5d4 100644 --- a/src/tools/qucom_p.h +++ b/src/tools/qucom_p.h @@ -127,7 +127,7 @@ extern Q_EXPORT QUType_Null static_QUType_Null; struct Q_EXPORT QUObject { public: // scary MSVC bug makes this necessary - QUObject() : type( &static_QUType_Null ) {} + QUObject() : type( &static_QUType_Null ), isLastObject(false) {} ~QUObject() { type->clear( this ); } QUType *type; @@ -184,6 +184,8 @@ public: // scary MSVC bug makes this necessary } payload; + QUObject* deepCopy(QUObject*); + bool isLastObject; }; -- cgit v1.2.1