mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-25 18:52:22 -05:00
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:
parent
cb39327b1c
commit
629036edfe
Notes:
sideshowbarker
2024-07-19 08:47:06 +09:00
Author: https://github.com/tlmrgvf Commit: https://github.com/SerenityOS/serenity/commit/629036edfe0 Pull-request: https://github.com/SerenityOS/serenity/pull/1407 Issue: https://github.com/SerenityOS/serenity/issues/1398
1 changed files with 4 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue