Browse Source

button crash guard if no text found

master
Odilitime 5 years ago
parent
commit
2638c8a480
  1. 17
      src/graphics/components/DocumentComponent.cpp

17
src/graphics/components/DocumentComponent.cpp

@ -378,13 +378,16 @@ void DocumentComponent::createComponentTree(const std::shared_ptr<Node> node, co @@ -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