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);
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();
if (!value.empty()) {
std::string temp;

View file

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

View file

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