Use QScopedValueRollback more as a reentrancy guard
It is documented for the use, but we were rarely using it. Change-Id: I812b9e6c8fbf204aba43ce2b79eca308ca75de88 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
e79b1dcdf5
commit
742a07ece1
@ -152,6 +152,7 @@
|
|||||||
#include <QtCore/qthreadstorage.h>
|
#include <QtCore/qthreadstorage.h>
|
||||||
#include <QtCore/qcoreevent.h>
|
#include <QtCore/qcoreevent.h>
|
||||||
#include <QtCore/qpointer.h>
|
#include <QtCore/qpointer.h>
|
||||||
|
#include <QtCore/qscopedvaluerollback.h>
|
||||||
|
|
||||||
#define DEFAULT_TIMER_INTERVAL 16
|
#define DEFAULT_TIMER_INTERVAL 16
|
||||||
#define PAUSE_TIMER_COARSE_THRESHOLD 2000
|
#define PAUSE_TIMER_COARSE_THRESHOLD 2000
|
||||||
@ -315,14 +316,13 @@ void QUnifiedTimer::updateAnimationTimers(qint64 currentTick)
|
|||||||
//* it might happen in some cases that the delta is negative because the animation driver
|
//* it might happen in some cases that the delta is negative because the animation driver
|
||||||
// advances faster than time.elapsed()
|
// advances faster than time.elapsed()
|
||||||
if (delta > 0) {
|
if (delta > 0) {
|
||||||
insideTick = true;
|
QScopedValueRollback<bool> guard(insideTick, true);
|
||||||
if (profilerCallback)
|
if (profilerCallback)
|
||||||
profilerCallback(delta);
|
profilerCallback(delta);
|
||||||
for (currentAnimationIdx = 0; currentAnimationIdx < animationTimers.count(); ++currentAnimationIdx) {
|
for (currentAnimationIdx = 0; currentAnimationIdx < animationTimers.count(); ++currentAnimationIdx) {
|
||||||
QAbstractAnimationTimer *animation = animationTimers.at(currentAnimationIdx);
|
QAbstractAnimationTimer *animation = animationTimers.at(currentAnimationIdx);
|
||||||
animation->updateAnimationsTime(delta);
|
animation->updateAnimationsTime(delta);
|
||||||
}
|
}
|
||||||
insideTick = false;
|
|
||||||
currentAnimationIdx = 0;
|
currentAnimationIdx = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -361,10 +361,11 @@ void QUnifiedTimer::localRestart()
|
|||||||
|
|
||||||
void QUnifiedTimer::restart()
|
void QUnifiedTimer::restart()
|
||||||
{
|
{
|
||||||
insideRestart = true;
|
{
|
||||||
|
QScopedValueRollback<bool> guard(insideRestart, true);
|
||||||
for (int i = 0; i < animationTimers.count(); ++i)
|
for (int i = 0; i < animationTimers.count(); ++i)
|
||||||
animationTimers.at(i)->restartAnimationTimer();
|
animationTimers.at(i)->restartAnimationTimer();
|
||||||
insideRestart = false;
|
}
|
||||||
|
|
||||||
localRestart();
|
localRestart();
|
||||||
}
|
}
|
||||||
@ -599,14 +600,13 @@ void QAnimationTimer::updateAnimationsTime(qint64 delta)
|
|||||||
//it might happen in some cases that the time doesn't change because events are delayed
|
//it might happen in some cases that the time doesn't change because events are delayed
|
||||||
//when the CPU load is high
|
//when the CPU load is high
|
||||||
if (delta) {
|
if (delta) {
|
||||||
insideTick = true;
|
QScopedValueRollback<bool> guard(insideTick, true);
|
||||||
for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) {
|
for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) {
|
||||||
QAbstractAnimation *animation = animations.at(currentAnimationIdx);
|
QAbstractAnimation *animation = animations.at(currentAnimationIdx);
|
||||||
int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime
|
int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime
|
||||||
+ (animation->direction() == QAbstractAnimation::Forward ? delta : -delta);
|
+ (animation->direction() == QAbstractAnimation::Forward ? delta : -delta);
|
||||||
animation->setCurrentTime(elapsed);
|
animation->setCurrentTime(elapsed);
|
||||||
}
|
}
|
||||||
insideTick = false;
|
|
||||||
currentAnimationIdx = 0;
|
currentAnimationIdx = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
#include <qdir.h>
|
#include <qdir.h>
|
||||||
|
#include <qscopedvaluerollback.h>
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
#include <qtimer.h>
|
#include <qtimer.h>
|
||||||
#endif
|
#endif
|
||||||
@ -1062,9 +1063,8 @@ bool QProcessPrivate::tryReadFromChannel(Channel *channel)
|
|||||||
if (currentReadChannel == channelIdx) {
|
if (currentReadChannel == channelIdx) {
|
||||||
didRead = true;
|
didRead = true;
|
||||||
if (!emittedReadyRead) {
|
if (!emittedReadyRead) {
|
||||||
emittedReadyRead = true;
|
QScopedValueRollback<bool> guard(emittedReadyRead, true);
|
||||||
emit q->readyRead();
|
emit q->readyRead();
|
||||||
emittedReadyRead = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit q->channelReadyRead(int(channelIdx));
|
emit q->channelReadyRead(int(channelIdx));
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include "qwindowspipereader_p.h"
|
#include "qwindowspipereader_p.h"
|
||||||
#include "qiodevice_p.h"
|
#include "qiodevice_p.h"
|
||||||
#include <qelapsedtimer.h>
|
#include <qelapsedtimer.h>
|
||||||
|
#include <qscopedvaluerollback.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -301,9 +302,8 @@ void QWindowsPipeReader::emitPendingReadyRead()
|
|||||||
{
|
{
|
||||||
if (readyReadPending) {
|
if (readyReadPending) {
|
||||||
readyReadPending = false;
|
readyReadPending = false;
|
||||||
inReadyRead = true;
|
QScopedValueRollback<bool> guard(inReadyRead, true);
|
||||||
emit readyRead();
|
emit readyRead();
|
||||||
inReadyRead = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#include "qwindowspipewriter_p.h"
|
#include "qwindowspipewriter_p.h"
|
||||||
#include "qiodevice_p.h"
|
#include "qiodevice_p.h"
|
||||||
|
#include <qscopedvaluerollback.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -111,9 +112,8 @@ void QWindowsPipeWriter::emitPendingBytesWrittenValue()
|
|||||||
|
|
||||||
emit canWrite();
|
emit canWrite();
|
||||||
if (!inBytesWritten) {
|
if (!inBytesWritten) {
|
||||||
inBytesWritten = true;
|
QScopedValueRollback<bool> guard(inBytesWritten, true);
|
||||||
emit bytesWritten(bytes);
|
emit bytesWritten(bytes);
|
||||||
inBytesWritten = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "qbezier_p.h"
|
#include "qbezier_p.h"
|
||||||
#include "qmath.h"
|
#include "qmath.h"
|
||||||
#include "qpainterpath_p.h"
|
#include "qpainterpath_p.h"
|
||||||
|
#include "qscopedvaluerollback.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
@ -354,7 +355,7 @@ void QOutlineMapper::clipElements(const QPointF *elements,
|
|||||||
// instead of going through convenience functionallity, but since
|
// instead of going through convenience functionallity, but since
|
||||||
// this part of code hardly every used, it shouldn't matter.
|
// this part of code hardly every used, it shouldn't matter.
|
||||||
|
|
||||||
m_in_clip_elements = true;
|
QScopedValueRollback<bool> in_clip_elements(m_in_clip_elements, true);
|
||||||
|
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
|
|
||||||
@ -397,8 +398,6 @@ void QOutlineMapper::clipElements(const QPointF *elements,
|
|||||||
convertPath(clippedPath);
|
convertPath(clippedPath);
|
||||||
m_transform = oldTransform;
|
m_transform = oldTransform;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_in_clip_elements = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include <private/qtextdocument_p.h>
|
#include <private/qtextdocument_p.h>
|
||||||
#include <qtextlayout.h>
|
#include <qtextlayout.h>
|
||||||
#include <qpointer.h>
|
#include <qpointer.h>
|
||||||
|
#include <qscopedvaluerollback.h>
|
||||||
#include <qtextobject.h>
|
#include <qtextobject.h>
|
||||||
#include <qtextcursor.h>
|
#include <qtextcursor.h>
|
||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
@ -68,14 +69,14 @@ public:
|
|||||||
void reformatBlocks(int from, int charsRemoved, int charsAdded);
|
void reformatBlocks(int from, int charsRemoved, int charsAdded);
|
||||||
void reformatBlock(const QTextBlock &block);
|
void reformatBlock(const QTextBlock &block);
|
||||||
|
|
||||||
inline void rehighlight(QTextCursor &cursor, QTextCursor::MoveOperation operation) {
|
inline void rehighlight(QTextCursor &cursor, QTextCursor::MoveOperation operation)
|
||||||
inReformatBlocks = true;
|
{
|
||||||
|
QScopedValueRollback<bool> bg(inReformatBlocks, true);
|
||||||
cursor.beginEditBlock();
|
cursor.beginEditBlock();
|
||||||
int from = cursor.position();
|
int from = cursor.position();
|
||||||
cursor.movePosition(operation);
|
cursor.movePosition(operation);
|
||||||
reformatBlocks(from, 0, cursor.position() - from);
|
reformatBlocks(from, 0, cursor.position() - from);
|
||||||
cursor.endEditBlock();
|
cursor.endEditBlock();
|
||||||
inReformatBlocks = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void _q_delayedRehighlight() {
|
inline void _q_delayedRehighlight() {
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include <private/qtools_p.h>
|
#include <private/qtools_p.h>
|
||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
|
|
||||||
|
#include <qscopedvaluerollback.h>
|
||||||
#include "qtextdocument_p.h"
|
#include "qtextdocument_p.h"
|
||||||
#include "qtextdocument.h"
|
#include "qtextdocument.h"
|
||||||
#include <qtextformat.h>
|
#include <qtextformat.h>
|
||||||
@ -274,9 +275,10 @@ void QTextDocumentPrivate::clear()
|
|||||||
rtFrame = 0;
|
rtFrame = 0;
|
||||||
init();
|
init();
|
||||||
cursors = oldCursors;
|
cursors = oldCursors;
|
||||||
inContentsChange = true;
|
{
|
||||||
|
QScopedValueRollback<bool> bg(inContentsChange, true);
|
||||||
emit q->contentsChange(0, len, 0);
|
emit q->contentsChange(0, len, 0);
|
||||||
inContentsChange = false;
|
}
|
||||||
if (lout)
|
if (lout)
|
||||||
lout->documentChanged(0, len, 0);
|
lout->documentChanged(0, len, 0);
|
||||||
} QT_CATCH(...) {
|
} QT_CATCH(...) {
|
||||||
@ -309,9 +311,10 @@ void QTextDocumentPrivate::setLayout(QAbstractTextDocumentLayout *layout)
|
|||||||
it->free();
|
it->free();
|
||||||
|
|
||||||
emit q->documentLayoutChanged();
|
emit q->documentLayoutChanged();
|
||||||
inContentsChange = true;
|
{
|
||||||
|
QScopedValueRollback<bool> bg(inContentsChange, true);
|
||||||
emit q->contentsChange(0, 0, length());
|
emit q->contentsChange(0, 0, length());
|
||||||
inContentsChange = false;
|
}
|
||||||
if (lout)
|
if (lout)
|
||||||
lout->documentChanged(0, 0, length());
|
lout->documentChanged(0, 0, length());
|
||||||
}
|
}
|
||||||
@ -1213,9 +1216,8 @@ void QTextDocumentPrivate::finishEdit()
|
|||||||
|
|
||||||
if (lout && docChangeFrom >= 0) {
|
if (lout && docChangeFrom >= 0) {
|
||||||
if (!inContentsChange) {
|
if (!inContentsChange) {
|
||||||
inContentsChange = true;
|
QScopedValueRollback<bool> bg(inContentsChange, true);
|
||||||
emit q->contentsChange(docChangeFrom, docChangeOldLength, docChangeLength);
|
emit q->contentsChange(docChangeFrom, docChangeOldLength, docChangeLength);
|
||||||
inContentsChange = false;
|
|
||||||
}
|
}
|
||||||
lout->documentChanged(docChangeFrom, docChangeOldLength, docChangeLength);
|
lout->documentChanged(docChangeFrom, docChangeOldLength, docChangeLength);
|
||||||
}
|
}
|
||||||
|
@ -339,6 +339,7 @@ private:
|
|||||||
int lastBlockCount;
|
int lastBlockCount;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
bool inContentsChange;
|
||||||
QTextOption defaultTextOption;
|
QTextOption defaultTextOption;
|
||||||
Qt::CursorMoveStyle defaultCursorMoveStyle;
|
Qt::CursorMoveStyle defaultCursorMoveStyle;
|
||||||
#ifndef QT_NO_CSSPARSER
|
#ifndef QT_NO_CSSPARSER
|
||||||
@ -346,7 +347,6 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
int maximumBlockCount;
|
int maximumBlockCount;
|
||||||
uint needsEnsureMaximumBlockCount : 1;
|
uint needsEnsureMaximumBlockCount : 1;
|
||||||
uint inContentsChange : 1;
|
|
||||||
uint blockCursorAdjustment : 1;
|
uint blockCursorAdjustment : 1;
|
||||||
QSizeF pageSize;
|
QSizeF pageSize;
|
||||||
QString title;
|
QString title;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user