Browse Source

Attempt to trace crash caused by iterator invalidation

Ivan Savenko 2 years ago
parent
commit
5fb5513572
1 changed files with 6 additions and 0 deletions
  1. 6 0
      client/gui/CGuiHandler.cpp

+ 6 - 0
client/gui/CGuiHandler.cpp

@@ -98,9 +98,12 @@ void CGuiHandler::init()
 	pointerSpeedMultiplier = settings["general"]["relativePointerSpeedMultiplier"].Float();
 }
 
+static bool debugDetectDeactivationDuringHandle = false;
+
 void CGuiHandler::handleElementActivate(CIntObject * elem, ui16 activityFlag)
 {
 	processLists(activityFlag,[&](std::list<CIntObject*> * lst){
+		assert(debugDetectDeactivationDuringHandle == false);
 		lst->push_front(elem);
 	});
 	elem->active_m |= activityFlag;
@@ -109,6 +112,7 @@ void CGuiHandler::handleElementActivate(CIntObject * elem, ui16 activityFlag)
 void CGuiHandler::handleElementDeActivate(CIntObject * elem, ui16 activityFlag)
 {
 	processLists(activityFlag,[&](std::list<CIntObject*> * lst){
+		assert(debugDetectDeactivationDuringHandle == false);
 		auto hlp = std::find(lst->begin(),lst->end(),elem);
 		assert(hlp != lst->end());
 		lst->erase(hlp);
@@ -594,6 +598,7 @@ void CGuiHandler::handleMouseMotion(const SDL_Event & current)
 	//sending active, hovered hoverable objects hover() call
 	std::vector<CIntObject*> hlp;
 
+	debugDetectDeactivationDuringHandle = true;
 	auto hoverableCopy = hoverable;
 	for(auto & elem : hoverableCopy)
 	{
@@ -608,6 +613,7 @@ void CGuiHandler::handleMouseMotion(const SDL_Event & current)
 			(elem)->hovered = false;
 		}
 	}
+	debugDetectDeactivationDuringHandle = false;
 	assert(hoverableCopy == hoverable);
 
 	for(auto & elem : hlp)