mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 21:30:04 +00:00 
			
		
		
		
	swkbd: Fix a bug where clicking Cancel hangs the game (#5294)
* swkbd: Fix a bug where clicking Cancel hangs the game The text is validated in `Finalize`. If the validation fails, an error is returned and the applet is not actually finalized. This can result in hangs. This is usually not a problem as the frontend is expected to validate the text passed to `Finalize`. However, when the user clicked on `Cancel`, the text is ignored and the frontend won't do any validation. Therefore, we should skip the validation here as well. Also fixed a potential data race. All these functions should now be called on the same thread * Address review comments Renamed the fields Remove close button
This commit is contained in:
		
							parent
							
								
									41bff0e3b7
								
							
						
					
					
						commit
						60669a7dd8
					
				
					 4 changed files with 21 additions and 13 deletions
				
			
		|  | @ -120,12 +120,15 @@ ValidationError SoftwareKeyboard::ValidateButton(u8 button) const { | |||
| } | ||||
| 
 | ||||
| ValidationError SoftwareKeyboard::Finalize(const std::string& text, u8 button) { | ||||
|     ValidationError error; | ||||
|     if ((error = ValidateInput(text)) != ValidationError::None) { | ||||
|         return error; | ||||
|     } | ||||
|     if ((error = ValidateButton(button)) != ValidationError::None) { | ||||
|         return error; | ||||
|     // Skip check when OK is not pressed
 | ||||
|     if (button == static_cast<u8>(config.button_config)) { | ||||
|         ValidationError error; | ||||
|         if ((error = ValidateInput(text)) != ValidationError::None) { | ||||
|             return error; | ||||
|         } | ||||
|         if ((error = ValidateButton(button)) != ValidationError::None) { | ||||
|             return error; | ||||
|         } | ||||
|     } | ||||
|     data = {text, button}; | ||||
|     data_ready = true; | ||||
|  |  | |||
|  | @ -4,7 +4,6 @@ | |||
| 
 | ||||
| #pragma once | ||||
| 
 | ||||
| #include <atomic> | ||||
| #include <unordered_map> | ||||
| #include <utility> | ||||
| #include <vector> | ||||
|  | @ -135,7 +134,7 @@ protected: | |||
|     KeyboardConfig config; | ||||
|     KeyboardData data; | ||||
| 
 | ||||
|     std::atomic_bool data_ready = false; | ||||
|     bool data_ready = false; | ||||
| }; | ||||
| 
 | ||||
| class DefaultKeyboard final : public SoftwareKeyboard { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue