From 629036edfe0fcf8f64d261d41eca1cc1860805c8 Mon Sep 17 00:00:00 2001 From: Till Mayer Date: Tue, 10 Mar 2020 14:47:30 +0100 Subject: [PATCH] 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. --- Games/Solitaire/SolitaireWidget.cpp | 6 ++++-- 1 file 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;