Browse Source

Fixed possible freezes while dragging visible area on minimap (#638)

Arseniy Lartsev 5 years ago
parent
commit
fca9bcdd7f
1 changed files with 8 additions and 0 deletions
  1. 8 0
      client/gui/CGuiHandler.cpp

+ 8 - 0
client/gui/CGuiHandler.cpp

@@ -194,6 +194,14 @@ void CGuiHandler::handleEvents()
 		SDL_Event ev = events.front();
 		current = &ev;
 		events.pop();
+
+		// In a sequence of mouse motion events, skip all but the last one.
+		// This prevents freezes when every motion event takes longer to handle than interval at which
+		// the events arrive (like dragging on the minimap in world view, with redraw at every event)
+		// so that the events would start piling up faster than they can be processed.
+		if ((ev.type == SDL_MOUSEMOTION) && !events.empty() && (events.front().type == SDL_MOUSEMOTION))
+			continue;
+
 		handleCurrentEvent();
 	}
 }