diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2023-01-20 12:45:02 +0000 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-01-22 21:31:36 +0000 |
commit | 8b3a94ffbc43d55b48a6038253f96d66838c4da1 (patch) | |
tree | 5a4992f58c4ddf17f9733e4b573369788373695b /Userland/Libraries/LibCards/CardStack.cpp | |
parent | 83687f85df7fd1b454fecee27699c445568b18f3 (diff) | |
download | serenity-8b3a94ffbc43d55b48a6038253f96d66838c4da1.zip |
LibCards+Games+GamesSettings: Return ErrorOr from CardStack::push()
Very few of these calls can propagate their errors yet, but one step at
a time. :^)
Diffstat (limited to 'Userland/Libraries/LibCards/CardStack.cpp')
-rw-r--r-- | Userland/Libraries/LibCards/CardStack.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Userland/Libraries/LibCards/CardStack.cpp b/Userland/Libraries/LibCards/CardStack.cpp index acb2a732ee..8d03708f4c 100644 --- a/Userland/Libraries/LibCards/CardStack.cpp +++ b/Userland/Libraries/LibCards/CardStack.cpp @@ -290,7 +290,7 @@ bool CardStack::make_top_card_visible() return false; } -void CardStack::push(NonnullRefPtr<Card> card) +ErrorOr<void> CardStack::push(NonnullRefPtr<Card> card) { auto top_most_position = m_stack_positions.is_empty() ? m_position : m_stack_positions.last(); @@ -306,9 +306,10 @@ void CardStack::push(NonnullRefPtr<Card> card) card->set_position(top_most_position); - m_stack.append(card); - m_stack_positions.append(top_most_position); + TRY(m_stack.try_append(card)); + TRY(m_stack_positions.try_append(top_most_position)); calculate_bounding_box(); + return {}; } NonnullRefPtr<Card> CardStack::pop() @@ -323,15 +324,16 @@ NonnullRefPtr<Card> CardStack::pop() return card; } -void CardStack::take_all(CardStack& stack) +ErrorOr<void> CardStack::take_all(CardStack& stack) { while (!m_stack.is_empty()) { auto card = m_stack.take_first(); m_stack_positions.take_first(); - stack.push(move(card)); + TRY(stack.push(move(card))); } calculate_bounding_box(); + return {}; } void CardStack::calculate_bounding_box() |