Switched UIFrame and Scene to store their UIDrawables in shared_ptr to vector, instead of directly to vector. Every object that can be exposed to Python has to be safely shareable so it doesn't become a segfault, and that includes the UIDrawable collections AND the UIDrawable members. So we get the terrifying type for collections of child elements: 'std::shared_ptr<std::vector<std::shared_ptr<UIDrawable>>>'. May I be forgiven for my sins

This commit is contained in:
John McCardle 2023-09-02 14:00:48 -04:00
commit 0ef0a5d506
7 changed files with 32 additions and 15 deletions

View file

@ -38,7 +38,7 @@ public:
//Simulate RectangleShape
float x, y, w, h, outline;
std::vector<std::shared_ptr<UIDrawable>> children;
std::shared_ptr<std::vector<std::shared_ptr<UIDrawable>>> children;
void render(sf::Vector2f) override final;
void move(sf::Vector2f);
@ -391,7 +391,7 @@ namespace mcrfpydef {
"outline=" << box.getOutlineThickness() << ", " <<
"fill_color=(" << (int)fc.r << ", " << (int)fc.g << ", " << (int)fc.b << ", " << (int)fc.a <<"), " <<
"outlinecolor=(" << (int)oc.r << ", " << (int)oc.g << ", " << (int)oc.b << ", " << (int)oc.a <<"), " <<
self->data->children.size() << " child" << (self->data->children.size() == 1 ? "" : "ren") << " objects" <<
self->data->children->size() << " child objects" <<
")>";
}
std::string repr_str = ss.str();