mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-04 03:15:59 -04:00
Add explicit check for nullptr before destroying SDL objects
This is not really needed as SDL has these checks internally, but this way it's still safer and more apparent that moved-from objects are handled properly.
This commit is contained in:
parent
411c62a3cc
commit
c3702a1eb8
@ -38,7 +38,8 @@ Renderer::Renderer(Window& window, int index, Uint32 flags) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Renderer::~Renderer() {
|
Renderer::~Renderer() {
|
||||||
SDL_DestroyRenderer(renderer_);
|
if (renderer_ != nullptr)
|
||||||
|
SDL_DestroyRenderer(renderer_);
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer::Renderer(Renderer&& other) noexcept : renderer_(other.renderer_) {
|
Renderer::Renderer(Renderer&& other) noexcept : renderer_(other.renderer_) {
|
||||||
|
@ -36,7 +36,8 @@ Texture::Texture(Renderer& renderer, Uint32 format, int access, int w, int h) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Texture::~Texture() {
|
Texture::~Texture() {
|
||||||
SDL_DestroyTexture(texture_);
|
if (texture_ != nullptr)
|
||||||
|
SDL_DestroyTexture(texture_);
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture::Texture(Texture&& other) noexcept : texture_(other.texture_) {
|
Texture::Texture(Texture&& other) noexcept : texture_(other.texture_) {
|
||||||
|
@ -32,7 +32,8 @@ Window::Window(const char* title, int x, int y, int w, int h, Uint32 flags) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Window::~Window() {
|
Window::~Window() {
|
||||||
SDL_DestroyWindow(window_);
|
if (window_ != nullptr)
|
||||||
|
SDL_DestroyWindow(window_);
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::Window(Window&& other) noexcept : window_(other.window_) {
|
Window::Window(Window&& other) noexcept : window_(other.window_) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user