X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fvideo%2Fsdl%2Fsdl_texture.hpp;h=97c38cb9531813df14ecccaacb71028178d59108;hb=c1277f5b7db9f55d1d28f658b4e804f32b76f0ce;hp=9f3a66737acde77c648258b897de88755d0eecca;hpb=12a28b64dcce9c7ff706451b4f3aecd201cc8a5f;p=supertux.git diff --git a/src/video/sdl/sdl_texture.hpp b/src/video/sdl/sdl_texture.hpp index 9f3a66737..97c38cb95 100644 --- a/src/video/sdl/sdl_texture.hpp +++ b/src/video/sdl/sdl_texture.hpp @@ -60,16 +60,22 @@ protected: memset(data, 0, CACHE_SIZE * sizeof(SDL_Surface *)); } + ColorCache(const ColorCache&); + ~ColorCache() { std::for_each(data, data + CACHE_SIZE, SDL_FreeSurface); } - void operator = (const ColorCache &other) + ColorCache& operator=(const ColorCache &other) { - std::for_each(other.data, other.data + CACHE_SIZE, ref); - std::for_each(data, data + CACHE_SIZE, SDL_FreeSurface); - memcpy(data, other.data, CACHE_SIZE * sizeof(SDL_Surface *)); + if (this != &other) + { + std::for_each(other.data, other.data + CACHE_SIZE, ref); + std::for_each(data, data + CACHE_SIZE, SDL_FreeSurface); + memcpy(data, other.data, CACHE_SIZE * sizeof(SDL_Surface *)); + } + return *this; } SDL_Surface *&operator [] (const Color &color)