Fix assertion violation in event loop tracking.
This commit is contained in:
		
							parent
							
								
									0ede4bba72
								
							
						
					
					
						commit
						44e81269a3
					
				
					 1 changed files with 15 additions and 5 deletions
				
			
		| 
						 | 
					@ -469,10 +469,7 @@ uint64 Sandbox::installationTag() const {
 | 
				
			||||||
	return _launcher->installationTag();
 | 
						return _launcher->installationTag();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Sandbox::postponeCall(FnMut<void()> &&callable) {
 | 
					void Sandbox::checkForEmptyLoopNestingLevel() {
 | 
				
			||||||
	Expects(callable != nullptr);
 | 
					 | 
				
			||||||
	Expects(_eventNestingLevel >= _loopNestingLevel);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// _loopNestingLevel == _eventNestingLevel means that we had a
 | 
						// _loopNestingLevel == _eventNestingLevel means that we had a
 | 
				
			||||||
	// native event in a nesting loop that didn't get a notify() call
 | 
						// native event in a nesting loop that didn't get a notify() call
 | 
				
			||||||
	// after. That means we already have exited the nesting loop and
 | 
						// after. That means we already have exited the nesting loop and
 | 
				
			||||||
| 
						 | 
					@ -485,11 +482,17 @@ void Sandbox::postponeCall(FnMut<void()> &&callable) {
 | 
				
			||||||
		_loopNestingLevel = _previousLoopNestingLevels.back();
 | 
							_loopNestingLevel = _previousLoopNestingLevels.back();
 | 
				
			||||||
		_previousLoopNestingLevels.pop_back();
 | 
							_previousLoopNestingLevels.pop_back();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Sandbox::postponeCall(FnMut<void()> &&callable) {
 | 
				
			||||||
 | 
						Expects(callable != nullptr);
 | 
				
			||||||
 | 
						Expects(_eventNestingLevel >= _loopNestingLevel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						checkForEmptyLoopNestingLevel();
 | 
				
			||||||
	_postponedCalls.push_back({
 | 
						_postponedCalls.push_back({
 | 
				
			||||||
		_loopNestingLevel,
 | 
							_loopNestingLevel,
 | 
				
			||||||
		std::move(callable)
 | 
							std::move(callable)
 | 
				
			||||||
		});
 | 
						});
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Sandbox::incrementEventNestingLevel() {
 | 
					void Sandbox::incrementEventNestingLevel() {
 | 
				
			||||||
| 
						 | 
					@ -497,16 +500,23 @@ void Sandbox::incrementEventNestingLevel() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Sandbox::decrementEventNestingLevel() {
 | 
					void Sandbox::decrementEventNestingLevel() {
 | 
				
			||||||
 | 
						Expects(_eventNestingLevel >= _loopNestingLevel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (_eventNestingLevel == _loopNestingLevel) {
 | 
						if (_eventNestingLevel == _loopNestingLevel) {
 | 
				
			||||||
		_loopNestingLevel = _previousLoopNestingLevels.back();
 | 
							_loopNestingLevel = _previousLoopNestingLevels.back();
 | 
				
			||||||
		_previousLoopNestingLevels.pop_back();
 | 
							_previousLoopNestingLevels.pop_back();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	const auto processTillLevel = _eventNestingLevel - 1;
 | 
						const auto processTillLevel = _eventNestingLevel - 1;
 | 
				
			||||||
	processPostponedCalls(processTillLevel);
 | 
						processPostponedCalls(processTillLevel);
 | 
				
			||||||
 | 
						checkForEmptyLoopNestingLevel();
 | 
				
			||||||
	_eventNestingLevel = processTillLevel;
 | 
						_eventNestingLevel = processTillLevel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Ensures(_eventNestingLevel >= _loopNestingLevel);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Sandbox::registerEnterFromEventLoop() {
 | 
					void Sandbox::registerEnterFromEventLoop() {
 | 
				
			||||||
 | 
						Expects(_eventNestingLevel >= _loopNestingLevel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (_eventNestingLevel > _loopNestingLevel) {
 | 
						if (_eventNestingLevel > _loopNestingLevel) {
 | 
				
			||||||
		_previousLoopNestingLevels.push_back(_loopNestingLevel);
 | 
							_previousLoopNestingLevels.push_back(_loopNestingLevel);
 | 
				
			||||||
		_loopNestingLevel = _eventNestingLevel;
 | 
							_loopNestingLevel = _eventNestingLevel;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue