Exemple #1
0
LocalFork::MessageAction LocalFork::handleReceivedMessage(MessagePtr msg, const AffectedArea &area)
{
	// No local fork: nothing to do. It is possible that we get a message from ourselves
	// that is not in the local fork, but this is not an error. It could happen when
	// playing back recordings, for example.
	if(_messages.isEmpty())
		return CONCURRENT;

	// Check if this is our own message that has finished its roundtrip
	if(msg->contextId() == _messages.first()->contextId()) {
		if(msg.equals(_messages.first())) {
			_messages.removeFirst();
			_areas.removeFirst();
			return ALREADYDONE;

		} else {
			// Unusual, but not an error. This can happen when the layer is locked while drawing
			// or when an operator performs some function on behalf the user.
			qWarning("local fork out of sync: discarding...");
			clear();
			return ROLLBACK;
		}
	}

	// OK, so this is another user's message. Check if it is concurrent
	for(const AffectedArea &a : _areas) {
		if(!area.isConcurrentWith(a)) {
			return ROLLBACK;
		}
	}

	return CONCURRENT;
}