diff options
| author | Max Horn | 2006-09-16 19:31:23 +0000 |
|---|---|---|
| committer | Max Horn | 2006-09-16 19:31:23 +0000 |
| commit | 651d22b873754cf4907a67f0f3c7e18eafdd7636 (patch) | |
| tree | 372b7bc3c8c3f86437467ea95a197799291e1950 /base | |
| parent | fd12695e59832265cae1ba62f8092fe182f2d7a2 (diff) | |
| download | scummvm-rg350-651d22b873754cf4907a67f0f3c7e18eafdd7636.tar.gz scummvm-rg350-651d22b873754cf4907a67f0f3c7e18eafdd7636.tar.bz2 scummvm-rg350-651d22b873754cf4907a67f0f3c7e18eafdd7636.zip | |
* Added virtual Engine::getDebugger() method
* Removed code from errorString() methods that hooked the debugger(s)
into error(), in favor of using getDebugger() from within error()
* As a consequence, removed most custom errorString() methods
svn-id: r23894
Diffstat (limited to 'base')
| -rw-r--r-- | base/engine.cpp | 36 | ||||
| -rw-r--r-- | base/engine.h | 9 |
2 files changed, 39 insertions, 6 deletions
diff --git a/base/engine.cpp b/base/engine.cpp index 6db1c54a5d..6c915b2954 100644 --- a/base/engine.cpp +++ b/base/engine.cpp @@ -30,8 +30,13 @@ #include "common/savefile.h" #include "common/system.h" #include "sound/mixer.h" +#include "gui/debugger.h" #include "gui/message.h" +#ifdef _WIN32_WCE +extern bool isSmartphone(void); +#endif + /* FIXME - BIG HACK for MidiEmu */ Engine *g_engine = 0; @@ -165,26 +170,45 @@ void NORETURN CDECL error(const char *s, ...) { char buf_output[STRINGBUFLEN]; va_list va; + // Generate the full error message va_start(va, s); vsnprintf(buf_input, STRINGBUFLEN, s, va); va_end(va); -#ifndef __GP32__ + + // Next, give the active engine (if any) a chance to augment the + // error message if (g_engine) { g_engine->errorString(buf_input, buf_output); } else { strcpy(buf_output, buf_input); } -#else - strcpy(buf_output, buf_input); -#endif + + + // Print the error message to stderr #ifdef __GP32__ printf("ERROR: %s\n", buf_output); -#else -#ifndef _WIN32_WCE +#elif !defined(_WIN32_WCE) fprintf(stderr, "%s!\n", buf_output); #endif + + +#ifndef __GP32__ + // 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(buf_output); + debugger->onFrame(); + } + } +#endif + #if defined( USE_WINDBG ) #if defined( _WIN32_WCE ) diff --git a/base/engine.h b/base/engine.h index e4055edb22..85798c219b 100644 --- a/base/engine.h +++ b/base/engine.h @@ -34,6 +34,9 @@ namespace Common { class SaveFileManager; class TimerManager; } +namespace GUI { + class Debugger; +} class Engine { public: @@ -80,6 +83,12 @@ public: /** Initialized graphics and shows error message. */ void GUIErrorMessage(const Common::String msg); + + /** + * Return the engine's debugger instance, if any. Used by error() to + * invoke the debugger when a severe error is reported. + */ + virtual GUI::Debugger *getDebugger() { return 0; } }; extern Engine *g_engine; |
