From c798cce89d13ea394dc64085d70565a2dd4aa285 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 14 Jan 2018 19:25:38 -0400 Subject: [PATCH] Improve the error message given when love.event pumping functions are called with a Canvas active. --- src/modules/event/sdl/Event.cpp | 10 +++++----- src/modules/event/sdl/Event.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/event/sdl/Event.cpp b/src/modules/event/sdl/Event.cpp index c6961c363..7f1c19d3b 100644 --- a/src/modules/event/sdl/Event.cpp +++ b/src/modules/event/sdl/Event.cpp @@ -116,7 +116,7 @@ Event::~Event() void Event::pump() { - exceptionIfInRenderPass(); + exceptionIfInRenderPass("love.event.pump"); SDL_Event e; @@ -133,7 +133,7 @@ void Event::pump() Message *Event::wait() { - exceptionIfInRenderPass(); + exceptionIfInRenderPass("love.event.wait"); SDL_Event e; @@ -145,7 +145,7 @@ Message *Event::wait() void Event::clear() { - exceptionIfInRenderPass(); + exceptionIfInRenderPass("love.event.clear"); SDL_Event e; @@ -157,7 +157,7 @@ void Event::clear() love::event::Event::clear(); } -void Event::exceptionIfInRenderPass() +void Event::exceptionIfInRenderPass(const char *name) { // Some core OS graphics functionality (e.g. swap buffers on some platforms) // happens inside SDL_PumpEvents - which is called by SDL_PollEvent and @@ -165,7 +165,7 @@ void Event::exceptionIfInRenderPass() // is active. auto gfx = Module::getInstance(Module::M_GRAPHICS); if (gfx != nullptr && gfx->isCanvasActive()) - throw love::Exception("Cannot call this function while a Canvas is active in love.graphics."); + throw love::Exception("%s cannot be called while a Canvas is active in love.graphics.", name); } Message *Event::convert(const SDL_Event &e) diff --git a/src/modules/event/sdl/Event.h b/src/modules/event/sdl/Event.h index 8d4c7be9f..1dc6a132b 100644 --- a/src/modules/event/sdl/Event.h +++ b/src/modules/event/sdl/Event.h @@ -69,7 +69,7 @@ public: private: - void exceptionIfInRenderPass(); + void exceptionIfInRenderPass(const char *name); Message *convert(const SDL_Event &e); Message *convertJoystickEvent(const SDL_Event &e) const;