Explorar el Código

Fix highscore screen freeze when entering player name

waitForServerShutdown() was blocking on serverRunner->wait() while
holding interfaceMutex, preventing the GUI thread from processing
events or rendering frames. This caused the highscore name entry
screen to freeze after winning a game.

Release interfaceMutex during the blocking wait using makeUnlockGuard,
matching the existing pattern in endNetwork().

Also fix [&] lambda capture in the highscore input callback to [this]
to avoid a dangling reference to a stack variable (cursorPosition).
Tom hace 1 semana
padre
commit
620e7bfdbd
Se han modificado 2 ficheros con 7 adiciones y 2 borrados
  1. 6 1
      client/CServerHandler.cpp
  2. 1 1
      client/mainmenu/CHighScoreScreen.cpp

+ 6 - 1
client/CServerHandler.cpp

@@ -978,7 +978,12 @@ void CServerHandler::waitForServerShutdown()
 	if (!serverRunner)
 		return; // may not exist for guest in MP
 
-	serverRunner->wait();
+	{
+		// Release interfaceMutex while waiting for server thread to finish
+		// to avoid blocking the GUI thread (same pattern as endNetwork())
+		auto unlockInterface = vstd::makeUnlockGuard(ENGINE->interfaceMutex);
+		serverRunner->wait();
+	}
 	int exitCode = serverRunner->exitCode();
 	serverRunner.reset();
 

+ 1 - 1
client/mainmenu/CHighScoreScreen.cpp

@@ -332,7 +332,7 @@ void CHighScoreInputScreen::clickPressed(const Point & cursorPosition)
 	if(!input)
 	{
 		input = std::make_shared<CHighScoreInput>(calc.parameters[0].playerName,
-		[&] (std::string text)
+		[this] (std::string text)
 		{
 			if(!text.empty())
 			{