chore: add conditional to freeing Bitmap

This commit is contained in:
scawful
2022-08-17 14:47:06 -04:00
parent 5275a773b7
commit f3eb31766a

View File

@@ -40,14 +40,15 @@ class Bitmap {
private: private:
struct sdl_deleter { struct sdl_deleter {
void operator()(SDL_Texture *p) const { SDL_DestroyTexture(p); } void operator()(SDL_Texture *p) const { if (p) { SDL_DestroyTexture(p); p = nullptr; } }
void operator()(SDL_Surface *p) const { SDL_FreeSurface(p); } void operator()(SDL_Surface *p) const { if (p) { SDL_FreeSurface(p); p = nullptr;} }
}; };
int width_ = 0; int width_ = 0;
int height_ = 0; int height_ = 0;
int depth_ = 0; int depth_ = 0;
int data_size_ = 0; int data_size_ = 0;
bool freed_ = false;
uchar *pixel_data_; uchar *pixel_data_;
std::shared_ptr<SDL_Texture> texture_; std::shared_ptr<SDL_Texture> texture_;
std::shared_ptr<SDL_Surface> surface_; std::shared_ptr<SDL_Surface> surface_;