Solitaire: Make sure to not add card twice to m_focused_cards

There is a possibility that the same card gets added twice to
m_focused_cards when first mousedown_event fires and then
doubleclick_event, without the cards redrawing first. This would cause
mouseup_event to try to pop too many cards from the stack, causing an
assertion to fail.

When the system is laggy there is also a high possibility that
mousedown_event would fire twice without redrawing the cards first,
causing another assertion to fail. Addditional mousedown_events will
just be ignored now.
This commit is contained in:
Till Mayer 2020-03-10 14:47:30 +01:00 committed by Andreas Kling
parent cb39327b1c
commit 629036edfe
Notes: sideshowbarker 2024-07-19 08:47:06 +09:00

View file

@ -212,7 +212,7 @@ void SolitaireWidget::mousedown_event(GUI::MouseEvent& event)
update_score(5);
m_has_to_repaint = true;
}
} else {
} else if (m_focused_cards.is_empty()) {
to_check.add_all_grabbed_cards(click_location, m_focused_cards);
m_mouse_down_location = click_location;
to_check.set_focused(true);
@ -313,8 +313,10 @@ void SolitaireWidget::doubleclick_event(GUI::MouseEvent& event)
return;
}
auto click_location = event.position();
if (!m_focused_cards.is_empty())
return;
auto click_location = event.position();
for (auto& to_check : m_stacks) {
if (to_check.type() == CardStack::Type::Foundation)
continue;