From 56c05d5573c7145263ae35745c63818b5bb7a48d Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 11 Apr 2022 01:59:52 +0200 Subject: Matrix: test fix crash with reaction renderer --- src/Body.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Body.cpp b/src/Body.cpp index 2747a22..1451541 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -1491,9 +1491,11 @@ namespace QuickMedia { float reaction_max_height = 0.0f; for(int i = 0; i < (int)item->reactions.size(); ++i) { auto &reaction = item->reactions[i]; - reaction.text->updateGeometry(); - reaction.size = { reaction.text->getWidth(), reaction.text->getHeight() }; - reaction.num_lines = reaction.text->getNumLines(); + if(reaction.text) { + reaction.text->updateGeometry(); + reaction.size = { reaction.text->getWidth(), reaction.text->getHeight() }; + reaction.num_lines = reaction.text->getNumLines(); + } const float reaction_max_height_prev = reaction_max_height; reaction_max_height = std::max(reaction_max_height, reaction.size.y); reaction_background.set_size(mgl::vec2f(reaction.size.x + body_spacing[body_theme].reaction_background_padding_x * 2.0f, reaction.size.y + body_spacing[body_theme].reaction_background_padding_y * 2.0f)); @@ -1510,10 +1512,12 @@ namespace QuickMedia { reaction_offset_x = new_reaction_offset_x; } - reaction.text->set_position(reaction_background.get_position() + mgl::vec2f(body_spacing[body_theme].reaction_background_padding_x, - 4.0f + body_spacing[body_theme].reaction_background_padding_y)); + if(reaction.text) { + reaction.text->set_position(reaction_background.get_position() + mgl::vec2f(body_spacing[body_theme].reaction_background_padding_x, - 4.0f + body_spacing[body_theme].reaction_background_padding_y)); - reaction_background.draw(window); - reaction.text->draw(window); + reaction_background.draw(window); + reaction.text->draw(window); + } } item_pos.y += reaction_max_height + body_spacing[body_theme].reaction_padding_y; } -- cgit v1.2.3