Browse Source

button crash guard if no text found

master
Odilitime 4 years ago
parent
commit
2638c8a480
1 changed files with 10 additions and 7 deletions
  1. 10
    7
      src/graphics/components/DocumentComponent.cpp

+ 10
- 7
src/graphics/components/DocumentComponent.cpp View File

@@ -378,13 +378,16 @@ void DocumentComponent::createComponentTree(const std::shared_ptr<Node> node, co
}
// don't build text node of button component because it'll mess with the picking
if (typeOfComponent(component) == "button") {
TextNode *textNode = dynamic_cast<TextNode*>(node->children.front().get());
if (textNode) {
//std::cout << "Button text: " << textNode->text << std::endl;
ButtonComponent *buttonComponent = dynamic_cast<ButtonComponent*>(component.get());
if (buttonComponent) {
buttonComponent->value = textNode->text;
buttonComponent->updateText();
// if this button node has children, extract the text before discarding it
if (node->children.size()) {
TextNode *textNode = dynamic_cast<TextNode*>(node->children.front().get());
if (textNode) {
//std::cout << "Button text: " << textNode->text << std::endl;
ButtonComponent *buttonComponent = dynamic_cast<ButtonComponent*>(component.get());
if (buttonComponent) {
buttonComponent->value = textNode->text;
buttonComponent->updateText();
}
}
}
return;

Loading…
Cancel
Save