Преглед на файлове

simplify CGuiHandler::handleEvents()

Threre is no need to allow (and I doubt is was in fact possible with old code) new events to arrive during processing events. Let them to be processed in next frame.
AlexVinS преди 11 години
родител
ревизия
c2dd696e96
променени са 1 файла, в които са добавени 4 реда и са изтрити 12 реда
  1. 4 12
      client/gui/CGuiHandler.cpp

+ 4 - 12
client/gui/CGuiHandler.cpp

@@ -169,19 +169,11 @@ void CGuiHandler::updateTime()
 
 void CGuiHandler::handleEvents()
 {
-	while(true)
+	boost::unique_lock<boost::mutex> lock(eventsM);
+	while(!events.empty())
 	{
-		SDL_Event ev;
-		boost::unique_lock<boost::mutex> lock(eventsM);
-		if(events.empty())
-		{
-			return;
-		}
-		else
-		{
-			ev = events.front();
-			events.pop();
-		}
+		SDL_Event ev = events.front();
+		events.pop();		
 		this->handleEvent(&ev);
 	}
 }