ENGINES: Create a default debugger when needed if none is yet set

This commit is contained in:
Paul Gilbert 2020-02-09 11:06:20 -08:00 committed by Filippos Karapetis
parent 73f17c2ae0
commit 98f9c4f254
3 changed files with 18 additions and 4 deletions

View File

@ -112,7 +112,7 @@ bool DefaultEventManager::pollEvent(Common::Event &event) {
_currentKeyDown.ascii = Common::KEYCODE_BACKSPACE;
} else if (event.kbd.keycode == Common::KEYCODE_d && (_modifierState & Common::KBD_CTRL)) {
GUI::Debugger *debugger = g_engine->getDebugger();
GUI::Debugger *debugger = g_engine->getOrCreateDebugger();
if (debugger) {
debugger->attach();
debugger->onFrame();

View File

@ -86,7 +86,7 @@ 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();
GUI::Debugger *debugger = g_engine->getOrCreateDebugger();
#if defined(USE_TASKBAR)
g_system->getTaskbarManager()->notifyError();
@ -760,6 +760,15 @@ bool Engine::shouldQuit() {
return (eventMan->shouldQuit() || eventMan->shouldRTL());
}
GUI::Debugger *Engine::getOrCreateDebugger() {
if (!_debugger)
// Create a bare-bones debugger. This is useful for engines without their own
// debugger when an error occurs
_debugger = new GUI::Debugger();
return _debugger;
}
/*
EnginePlugin *Engine::getMetaEnginePlugin() const {
return EngineMan.findPlugin(ConfMan.get("engineid"));

View File

@ -174,8 +174,7 @@ public:
virtual void errorString(const char *buf_input, char *buf_output, int buf_output_size);
/**
* Return the engine's debugger instance, if any. Used by error() to
* invoke the debugger when a severe error is reported.
* Return the engine's debugger instance, if any.
*/
virtual GUI::Debugger *getDebugger() { return _debugger; }
@ -188,6 +187,12 @@ public:
_debugger = debugger;
}
/**
* Return the engine's debugger instance, or create one if none is present.
* Used by error() to invoke the debugger when a severe error is reported.
*/
GUI::Debugger *getOrCreateDebugger();
/**
* Determine whether the engine supports the specified feature.
*/