Don't wait in Document::lockToWrite() if timeout = 0

This fixes a lag problem using the arrow keys to move the selection
content.
This commit is contained in:
David Capello 2015-04-22 22:00:59 -03:00
parent a2cbf3f285
commit cd07acb6a0

View File

@ -570,9 +570,16 @@ bool Document::lockToWrite(int timeout)
return true;
}
}
timeout -= 100;
TRACE("Document::lockToWrite: wait 100 msecs for <%d>\n", id());
base::this_thread::sleep_for(0.100);
if (timeout > 0) {
int delay = MIN(100, timeout);
timeout -= delay;
TRACE("Document::lockToWrite: wait 100 msecs for <%d>\n", id());
base::this_thread::sleep_for(double(delay) / 1000.0);
}
else
break;
}
TRACE("Document::lockToWrite: Cannot lock <%d> to write (has %d read locks and %d write locks)\n",