fix segfault on application exit

This commit is contained in:
Sophia Hadash 2021-09-26 22:45:10 +02:00
parent 0587b220cc
commit a4d4493d3e
3 changed files with 18 additions and 10 deletions

View file

@ -48,11 +48,15 @@ BadgesComponent::BadgesComponent(Window *window)
mImageAltEmu.setImage(mBadgeIcons[SLOT_ALTERNATIVE_EMULATOR], false, true); mImageAltEmu.setImage(mBadgeIcons[SLOT_ALTERNATIVE_EMULATOR], false, true);
mImageComponents.insert({SLOT_ALTERNATIVE_EMULATOR, mImageAltEmu}); mImageComponents.insert({SLOT_ALTERNATIVE_EMULATOR, mImageAltEmu});
} }
} }
void BadgesComponent::setValue(const std::string& value) BadgesComponent::~BadgesComponent() {
{ mBadgeIcons.clear();
mImageComponents.clear();
}
void BadgesComponent::setValue(const std::string &value) {
mChildren.clear(); mChildren.clear();
if (!value.empty()) { if (!value.empty()) {
std::string temp; std::string temp;

View file

@ -27,7 +27,9 @@ class TextureResource;
class BadgesComponent : public FlexboxComponent class BadgesComponent : public FlexboxComponent
{ {
public: public:
BadgesComponent(Window* window); BadgesComponent(Window *window);
~BadgesComponent() noexcept;
std::string getValue() const override; std::string getValue() const override;
// Should be a list of strings. // Should be a list of strings.

View file

@ -14,21 +14,23 @@
class TextureResource; class TextureResource;
class ImageComponent : public GuiComponent class ImageComponent : public GuiComponent {
{
public: public:
ImageComponent(Window* window, bool forceLoad = false, bool dynamic = true); ImageComponent(Window *window, bool forceLoad = false, bool dynamic = true);
virtual ~ImageComponent() {}
virtual ~ImageComponent() noexcept {};
void setDefaultImage(std::string path) { mDefaultPath = path; } void setDefaultImage(std::string path) { mDefaultPath = path; }
// Loads the image at the given filepath. Will tile if tile is true (retrieves texture // Loads the image at the given filepath. Will tile if tile is true (retrieves texture
// as tiling, creates vertices accordingly). // as tiling, creates vertices accordingly).
void setImage(std::string path, bool tile = false, bool linearMagnify = false); void setImage(std::string path, bool tile = false, bool linearMagnify = false);
// Loads an image from memory. // Loads an image from memory.
void setImage(const char* data, size_t length, bool tile = false); void setImage(const char *data, size_t length, bool tile = false);
// Use an already existing texture. // Use an already existing texture.
void setImage(const std::shared_ptr<TextureResource>& texture); void setImage(const std::shared_ptr<TextureResource> &texture);
void onSizeChanged() override { updateVertices(); } void onSizeChanged() override { updateVertices(); }