diff options
author | Till Mayer <till.mayer@web.de> | 2020-03-10 14:47:30 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-11 10:06:00 +0100 |
commit | 629036edfe0fcf8f64d261d41eca1cc1860805c8 (patch) | |
tree | d923db79410276e220e867237d2661fab4e809b1 | |
parent | cb39327b1c8772516b359bb98f5bd80a4f52e8d1 (diff) | |
download | serenity-629036edfe0fcf8f64d261d41eca1cc1860805c8.zip |
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.
-rw-r--r-- | Games/Solitaire/SolitaireWidget.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Games/Solitaire/SolitaireWidget.cpp b/Games/Solitaire/SolitaireWidget.cpp index 7865be88f4..0d690b5c6d 100644 --- a/Games/Solitaire/SolitaireWidget.cpp +++ b/Games/Solitaire/SolitaireWidget.cpp @@ -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; |