Solve a segfault with piece animations

This commit is contained in:
Loic Guegan 2023-01-09 19:32:09 +01:00
parent 8e83bfb673
commit 179a173b3b

View file

@ -94,14 +94,16 @@ void GameTabLeftPanel::Notify(bool skip_animation) {
// Update capture and check if we should to animations during moves change: // Update capture and check if we should to animations during moves change:
if (m){ if (m){
captures = m->GetLineCaptures(); captures = m->GetLineCaptures();
if(m->HasParent(last_move)){ if(!m->IsVariation()){ // Animations can lead to segfault when clicking on CGEditor move
m->GetAbsoluteMove(src,dst); if(m->HasParent(last_move)){
animate=true; m->GetAbsoluteMove(src,dst);
}else if(m->HasChild(last_move)){ animate=true;
// Accessing last_move here is safe since it is still }else if(m->HasChild(last_move)){
// in the tree of moves (since HasChild found it so not deleted) // Accessing last_move here is safe since it is still
last_move->GetAbsoluteMove(dst,src); // in the tree of moves (since HasChild found it so not deleted)
animate=true; last_move->GetAbsoluteMove(dst,src);
animate=true;
}
} }
} else if(game->GetNextMove()){ // First move animation } else if(game->GetNextMove()){ // First move animation
HalfMove *next=game->GetNextMove(); HalfMove *next=game->GetNextMove();