From c30ba340b117d6fc8c3fb86686efb3e2021ef447 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Sun, 24 Jan 2021 10:01:32 +0100 Subject: [PATCH] partially reverted 481785a6 (debugger widgets needed for saveOldState) --- src/debugger/Debugger.cxx | 34 ++++++++++++++-------------------- src/debugger/Debugger.hxx | 9 ++------- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/debugger/Debugger.cxx b/src/debugger/Debugger.cxx index 5249e0363..29f73a705 100644 --- a/src/debugger/Debugger.cxx +++ b/src/debugger/Debugger.cxx @@ -84,6 +84,7 @@ Debugger::Debugger(OSystem& osystem, Console& console) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Debugger::~Debugger() { + delete myDialog; myDialog = nullptr; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -99,6 +100,11 @@ void Debugger::initialize() myOSystem.settings().setValue("dbg.res", mySize); + delete myDialog; myDialog = nullptr; + myDialog = new DebuggerDialog(myOSystem, *this, 0, 0, mySize.w, mySize.h); + + myCartDebug->setDebugWidget(&(myDialog->cartDebug())); + saveOldState(); } @@ -122,9 +128,9 @@ bool Debugger::start(const string& message, int address, bool read, ostringstream buf; buf << message; if(address > -1) - buf << cartDebug().getLabel(CartDebug::BankAddress(address), read, 4); - dialog().message().setText(buf.str()); - dialog().message().setToolTip(toolTip); + buf << cartDebug().getLabel(address, read, 4); + myDialog->message().setText(buf.str()); + myDialog->message().setToolTip(toolTip); return true; } return false; @@ -137,7 +143,7 @@ bool Debugger::startWithFatalError(const string& message) { // This must be done *after* we enter debug mode, // so the dialog is properly shown - dialog().showFatalMessage(message); + myDialog->showFatalMessage(message); return true; } return false; @@ -574,8 +580,8 @@ void Debugger::nextFrame(int frames) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Debugger::updateRewindbuttons(const RewindManager& r) { - dialog().rewindButton().setEnabled(!r.atFirst()); - dialog().unwindButton().setEnabled(!r.atLast()); + myDialog->rewindButton().setEnabled(!r.atFirst()); + myDialog->unwindButton().setEnabled(!r.atLast()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -679,13 +685,13 @@ void Debugger::setStartState() updateRewindbuttons(r); // Set the 're-disassemble' flag, but don't do it until the next scheduled time - dialog().rom().invalidate(false); + myDialog->rom().invalidate(false); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Debugger::setQuitState() { - dialog().saveConfig(); + myDialog->saveConfig(); saveOldState(); // Bus must be unlocked for normal operation when leaving debugger mode @@ -840,18 +846,6 @@ bool Debugger::canExit() const return baseDialogIsActive(); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -DebuggerDialog& Debugger::dialog() -{ - if(myDialog == nullptr) - { - myDialog = make_unique(myOSystem, *this, 0, 0, mySize.w, mySize.h); - myCartDebug->setDebugWidget(&(myDialog->cartDebug())); - } - - return *myDialog; -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - std::array Debugger::ourBuiltinFunctions = { { // left joystick: diff --git a/src/debugger/Debugger.hxx b/src/debugger/Debugger.hxx index 2623fb5d3..0e7de4c36 100644 --- a/src/debugger/Debugger.hxx +++ b/src/debugger/Debugger.hxx @@ -279,7 +279,7 @@ class Debugger : public DialogContainer /** Return (and possibly create) the bottom-most dialog of this container. */ - Dialog* baseDialog() override { return &dialog(); } + Dialog* baseDialog() override { return myDialog; } private: /** @@ -332,16 +332,11 @@ class Debugger : public DialogContainer void loadState(int state); void loadAllStates(); - /** - Return (and possibly create) the debugger dialog. - */ - DebuggerDialog& dialog(); - private: Console& myConsole; System& mySystem; - unique_ptr myDialog; + DebuggerDialog* myDialog{nullptr}; unique_ptr myParser; unique_ptr myCartDebug; unique_ptr myCpuDebug;