diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/engine.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/engines/engine.cpp b/engines/engine.cpp index 3c659a5d9e..d8aeb88278 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -31,11 +31,13 @@ #include "engines/engine.h" #include "common/config-manager.h" +#include "common/debug.h" #include "common/events.h" #include "common/file.h" #include "common/timer.h" #include "common/savefile.h" #include "common/system.h" +#include "gui/debugger.h" #include "gui/message.h" #include "gui/GuiManager.h" #include "sound/mixer.h" @@ -49,6 +51,32 @@ extern bool isSmartphone(); // FIXME: HACK for MidiEmu & error() Engine *g_engine = 0; +// Output formatter for debug() and error() which invokes +// the errorString method of the active engine, if any. +static void defaultOutputFormatter(char *dst, const char *src, size_t dstSize) { + if (g_engine) { + g_engine->errorString(src, dst, dstSize); + } else { + strncpy(dst, src, dstSize); + } +} + +static void defaultErrorHandler(const char *msg) { + // Unless this error -originated- within the debugger itself, we + // now invoke the debugger, if available / supported. + if (g_engine) { + GUI::Debugger *debugger = g_engine->getDebugger(); +#ifdef _WIN32_WCE + if (isSmartphone()) + debugger = 0; +#endif + if (debugger && !debugger->isAttached()) { + debugger->attach(msg); + debugger->onFrame(); + } + } +} + Engine::Engine(OSystem *syst) : _system(syst), @@ -62,6 +90,9 @@ Engine::Engine(OSystem *syst) _mainMenuDialog(NULL) { g_engine = this; + Common::setDebugOutputFormatter(defaultOutputFormatter); + Common::setErrorOutputFormatter(defaultOutputFormatter); + Common::setErrorHandler(defaultErrorHandler); // FIXME: Get rid of the following again. It is only here temporarily. // We really should never run with a non-working Mixer, so ought to handle |