diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 11 | ||||
-rw-r--r-- | src/corelib/thread/qthread_p.h | 11 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index c30f6135a9..2a80d39620 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -809,16 +809,7 @@ bool QCoreApplication::notifyInternal(QObject *receiver, QEvent *event) // call overhead. QObjectPrivate *d = receiver->d_func(); QThreadData *threadData = d->threadData; - - // Exception-safety without try/catch - struct Incrementer { - int &variable; - inline Incrementer(int &variable) : variable(variable) - { ++variable; } - inline ~Incrementer() - { --variable; } - }; - Incrementer inc(threadData->loopLevel); + QScopedLoopLevelCounter loopLevelCounter(threadData); #ifdef QT_JAMBI_BUILD int deleteWatch = 0; diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index 04f9bf23cf..66dd8db7c7 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -227,6 +227,17 @@ public: bool isAdopted; }; +class QScopedLoopLevelCounter +{ + QThreadData *threadData; +public: + inline QScopedLoopLevelCounter(QThreadData *threadData) + : threadData(threadData) + { ++threadData->loopLevel; } + inline ~QScopedLoopLevelCounter() + { --threadData->loopLevel; } +}; + // thread wrapper for the main() thread class QAdoptedThread : public QThread { |