diff --git a/SDL2pp/Texture.hh b/SDL2pp/Texture.hh index bb5eeac..d44c4a2 100644 --- a/SDL2pp/Texture.hh +++ b/SDL2pp/Texture.hh @@ -53,6 +53,7 @@ public: LockHandle(Texture* texture, const Rect& rect); public: + LockHandle(); ~LockHandle(); LockHandle(LockHandle&& other) noexcept; diff --git a/SDL2pp/TextureLock.cc b/SDL2pp/TextureLock.cc index 325276b..da0f09a 100644 --- a/SDL2pp/TextureLock.cc +++ b/SDL2pp/TextureLock.cc @@ -28,6 +28,9 @@ namespace SDL2pp { +Texture::LockHandle::LockHandle() : texture_(nullptr) { +} + Texture::LockHandle::LockHandle(Texture* texture, const Rect& rect) : texture_(texture) { if (SDL_LockTexture(texture_->Get(), rect.Get(), &pixels_, &pitch_) != 0) throw Exception("SDL_LockTexture failed"); @@ -35,6 +38,8 @@ Texture::LockHandle::LockHandle(Texture* texture, const Rect& rect) : texture_(t Texture::LockHandle::LockHandle(Texture::LockHandle&& other) noexcept : texture_(other.texture_), pixels_(other.pixels_), pitch_(other.pitch_) { other.texture_ = nullptr; + other.pixels_ = nullptr; + other.pitch_ = 0; } Texture::LockHandle& Texture::LockHandle::operator=(Texture::LockHandle&& other) noexcept { @@ -49,6 +54,8 @@ Texture::LockHandle& Texture::LockHandle::operator=(Texture::LockHandle&& other) pitch_ = other.pitch_; other.texture_ = nullptr; + other.pixels_ = nullptr; + other.pitch_ = 0; return *this; }