diff options
author | Darrell Anderson <[email protected]> | 2012-12-19 14:03:09 -0600 |
---|---|---|
committer | Darrell Anderson <[email protected]> | 2012-12-19 14:03:09 -0600 |
commit | 35202ed0d899a9ff3c77dad72b501fb30e4dcf93 (patch) | |
tree | 683787f69d937483b860973ce17f0c5d430a142d /src/tools | |
parent | 8d5add0e87ad913bdf0362a83f431995115f3bfa (diff) | |
parent | f19aa203c934d0f85862fdf810a87fe7c5777d17 (diff) | |
download | qt3-35202ed0d899a9ff3c77dad72b501fb30e4dcf93.tar.gz qt3-35202ed0d899a9ff3c77dad72b501fb30e4dcf93.zip |
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/qt3
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/qmutex.h | 3 | ||||
-rw-r--r-- | src/tools/qmutex_p.h | 1 | ||||
-rw-r--r-- | src/tools/qmutex_unix.cpp | 29 | ||||
-rw-r--r-- | src/tools/qthreadinstance_p.h | 6 | ||||
-rw-r--r-- | src/tools/qucom.cpp | 24 | ||||
-rw-r--r-- | src/tools/qucom_p.h | 4 |
6 files changed, 65 insertions, 2 deletions
diff --git a/src/tools/qmutex.h b/src/tools/qmutex.h index 9eb1a69..1dec4d2 100644 --- a/src/tools/qmutex.h +++ b/src/tools/qmutex.h @@ -74,6 +74,9 @@ private: QMutex( const QMutex & ); QMutex &operator=( const QMutex & ); #endif + +public: + int level(); }; class Q_EXPORT QMutexLocker diff --git a/src/tools/qmutex_p.h b/src/tools/qmutex_p.h index c80c349..d06839c 100644 --- a/src/tools/qmutex_p.h +++ b/src/tools/qmutex_p.h @@ -67,6 +67,7 @@ public: virtual bool locked() = 0; virtual bool trylock() = 0; virtual int type() const = 0; + virtual int level() = 0; }; diff --git a/src/tools/qmutex_unix.cpp b/src/tools/qmutex_unix.cpp index 7f14e6a..de0f909 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 <errno.h> #include <string.h> - // Private class declarations class QRealMutexPrivate : public QMutexPrivate { @@ -86,6 +85,7 @@ public: bool locked(); bool trylock(); int type() const; + int level(); bool recursive; }; @@ -102,6 +102,7 @@ public: bool locked(); bool trylock(); int type() const; + int level(); int count; unsigned long owner; @@ -197,6 +198,11 @@ int QRealMutexPrivate::type() const return recursive ? Q_MUTEX_RECURSIVE : Q_MUTEX_NORMAL; } +int QRealMutexPrivate::level() +{ + return locked(); +} + #ifndef Q_RECURSIVE_MUTEX_TYPE QRecursiveMutexPrivate::QRecursiveMutexPrivate() @@ -330,6 +336,11 @@ int QRecursiveMutexPrivate::type() const return Q_MUTEX_RECURSIVE; } +int QRecursiveMutexPrivate::level() +{ + return count; +} + #endif // !Q_RECURSIVE_MUTEX_TYPE @@ -512,6 +523,22 @@ bool QMutex::tryLock() } /*! + Returns the current lock level of the mutex. + 0 means the mutex is unlocked + This method should only be called when the mutex has already been locked + by lock(), otherwise the lock level could change before the next line + of code is executed. + + WARNING: Non-recursive mutexes will never exceed a lock level of 1! + + \sa lock(), unlock(), locked() +*/ +int QMutex::level() +{ + return d->level(); +} + +/*! \class QMutexLocker qmutex.h \brief The QMutexLocker class simplifies locking and unlocking QMutexes. 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 <pthread.h> #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; }; |