Merge pull request #7507 from AndrewMeadows/broken-time-machine

fix "deadlock" when setting clock backwards
This commit is contained in:
Brad Hefta-Gaub 2016-03-29 19:38:45 -07:00
commit 92ddf9d7ac
2 changed files with 13 additions and 4 deletions

View file

@ -561,6 +561,12 @@ bool ParticleEffectEntityItem::needsToCallUpdate() const {
void ParticleEffectEntityItem::update(const quint64& now) {
// we check for 'now' in the past in case users set their clock backward
if (now < _lastSimulated) {
_lastSimulated = now;
return;
}
float deltaTime = (float)(now - _lastSimulated) / (float)USECS_PER_SECOND;
_lastSimulated = now;

View file

@ -673,11 +673,14 @@ void ScriptEngine::run() {
}
qint64 now = usecTimestampNow();
float deltaTime = (float) (now - lastUpdate) / (float) USECS_PER_SECOND;
if (!_isFinished) {
if (_wantSignals) {
emit update(deltaTime);
// we check for 'now' in the past in case people set their clock back
if (lastUpdate < now) {
float deltaTime = (float) (now - lastUpdate) / (float) USECS_PER_SECOND;
if (!_isFinished) {
if (_wantSignals) {
emit update(deltaTime);
}
}
}
lastUpdate = now;