From 1c1f37b76e9ccde2c9e6e78e10abbf3ed325b4ee Mon Sep 17 00:00:00 2001 From: Carl Schwope Date: Thu, 14 Nov 2013 15:53:51 -0500 Subject: [PATCH 1/4] make destructors virtual --- SDL2pp/Exception.cc | 4 ++++ SDL2pp/Exception.hh | 1 + SDL2pp/Point.hh | 2 +- SDL2pp/Rect.hh | 2 +- SDL2pp/Renderer.hh | 2 +- SDL2pp/SDL.hh | 2 +- SDL2pp/Texture.hh | 2 +- SDL2pp/Window.hh | 2 +- 8 files changed, 11 insertions(+), 6 deletions(-) diff --git a/SDL2pp/Exception.cc b/SDL2pp/Exception.cc index 18cf4d4..5942661 100644 --- a/SDL2pp/Exception.cc +++ b/SDL2pp/Exception.cc @@ -28,6 +28,10 @@ namespace SDL2pp { Exception::Exception(const char* what) : what_(what), sdl_error_(SDL_GetError()) { } +Exception::~Exception() noexcept { + // nothing to do +} + const char* Exception::what() const noexcept { return what_; } diff --git a/SDL2pp/Exception.hh b/SDL2pp/Exception.hh index 4f46890..d4ffc8e 100644 --- a/SDL2pp/Exception.hh +++ b/SDL2pp/Exception.hh @@ -33,6 +33,7 @@ private: public: Exception(const char* what = ""); + virtual ~Exception() noexcept; const char* what() const noexcept; const char* GetSDLError() const noexcept; }; diff --git a/SDL2pp/Point.hh b/SDL2pp/Point.hh index 69e06c1..13703d5 100644 --- a/SDL2pp/Point.hh +++ b/SDL2pp/Point.hh @@ -45,7 +45,7 @@ private: public: Point(int x, int y); - ~Point(); + virtual ~Point(); static Point Null(); diff --git a/SDL2pp/Rect.hh b/SDL2pp/Rect.hh index 3cdf9ac..8c20d84 100644 --- a/SDL2pp/Rect.hh +++ b/SDL2pp/Rect.hh @@ -37,7 +37,7 @@ private: public: Rect(int x, int y, int w, int h); - ~Rect(); + virtual ~Rect(); static Rect Null(); diff --git a/SDL2pp/Renderer.hh b/SDL2pp/Renderer.hh index 7d7c37e..600cd0f 100644 --- a/SDL2pp/Renderer.hh +++ b/SDL2pp/Renderer.hh @@ -39,7 +39,7 @@ private: public: Renderer(Window& window, int index, Uint32 flags); - ~Renderer(); + virtual ~Renderer(); Renderer(const Renderer& other) = delete; Renderer(Renderer&& other) = delete; diff --git a/SDL2pp/SDL.hh b/SDL2pp/SDL.hh index f923da8..cb5edb0 100644 --- a/SDL2pp/SDL.hh +++ b/SDL2pp/SDL.hh @@ -29,7 +29,7 @@ namespace SDL2pp { class SDL { public: SDL(Uint32 flags); - ~SDL(); + virtual ~SDL(); SDL(const SDL& other) = delete; SDL(SDL&& other) = delete; diff --git a/SDL2pp/Texture.hh b/SDL2pp/Texture.hh index acdbea7..9e7410b 100644 --- a/SDL2pp/Texture.hh +++ b/SDL2pp/Texture.hh @@ -38,7 +38,7 @@ private: public: Texture(Renderer& renderer, Uint32 format, int access, int w, int h); - ~Texture(); + virtual ~Texture(); Texture(const Texture& other) = delete; Texture(Texture&& other) = delete; diff --git a/SDL2pp/Window.hh b/SDL2pp/Window.hh index afda315..86ee456 100644 --- a/SDL2pp/Window.hh +++ b/SDL2pp/Window.hh @@ -34,7 +34,7 @@ private: public: Window(const char* title, int x, int y, int w, int h, Uint32 flags); - ~Window(); + virtual ~Window(); Window(const Window& other) = delete; Window(Window&& other) = delete; From 0f48223d2b6d4c3e4bd7778c14e857e1ebe6f852 Mon Sep 17 00:00:00 2001 From: Carl Schwope Date: Thu, 14 Nov 2013 16:08:59 -0500 Subject: [PATCH 2/4] ignore cmake generated files --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..787b137 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# Ignore files generated by cmake +CMakeCache.txt +CMakeFiles/ +Makefile +cmake_install.cmake +libSDL2pp.so From 0e663f21d7cf3f9d49791d6c167edc361963949a Mon Sep 17 00:00:00 2001 From: Carl Schwope Date: Fri, 15 Nov 2013 01:44:22 -0500 Subject: [PATCH 3/4] call SDL_RenderFillRect --- SDL2pp/Renderer.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SDL2pp/Renderer.cc b/SDL2pp/Renderer.cc index 6e5b554..b11ee64 100644 --- a/SDL2pp/Renderer.cc +++ b/SDL2pp/Renderer.cc @@ -160,7 +160,7 @@ void Renderer::DrawRects(const Rect* rects, int count) { void Renderer::FillRect(int x1, int y1, int x2, int y2) { SDL_Rect rect = {x1, y1, x2 - x1 + 1, y2 - y1 + 1}; - if (SDL_RenderDrawRect(renderer_, &rect) != 0) + if (SDL_RenderFillRect(renderer_, &rect) != 0) throw Exception("SDL_RenderFillRect failed"); } @@ -173,7 +173,7 @@ void Renderer::FillRect(const Point& p1, const Point& p2) { void Renderer::FillRect(const Rect& r) { if (r.IsNull()) return; - if (SDL_RenderDrawRect(renderer_, r.Get()) != 0) + if (SDL_RenderFillRect(renderer_, r.Get()) != 0) throw Exception("SDL_RenderFillRect failed"); } From e183d4b454d154e173ee916bd83cc45f9e7bb30e Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Fri, 15 Nov 2013 18:55:01 +0400 Subject: [PATCH 4/4] Remove excessive comment --- SDL2pp/Exception.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/SDL2pp/Exception.cc b/SDL2pp/Exception.cc index 5942661..b5d2cb0 100644 --- a/SDL2pp/Exception.cc +++ b/SDL2pp/Exception.cc @@ -29,7 +29,6 @@ Exception::Exception(const char* what) : what_(what), sdl_error_(SDL_GetError()) } Exception::~Exception() noexcept { - // nothing to do } const char* Exception::what() const noexcept {