From c0b6e9e69cd7a0f5519824b5f24ec232d43590a7 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Mon, 17 Apr 2023 23:11:26 -0700 Subject: [PATCH 1/2] Treat --debugger command line as a temporary setting Before, Settings::SetDebugModeEnabled was used; this calls SetBaseOrCurrent() which will usually permanently change the base configuration setting for the debugger to true. Thus, the debugger would remain active even if the --debugger command line option was removed. Now, it remains active only for the current run, like other command-line options. Note that SetBaseOrCurrent is also used by the "Show Debugging UI" option under Options -> Interface; this means that if the debugger is turned off (or off and then back on) by the user while --debugger is specified, this will be reset to whatever the base configuration had when Dolphin is closed and reopened. This behavior is consistent with the rest of the UI. To my understanding, the --debugger option is something from 5.0 stable/DolphinWx where there was no way to toggle the debug UI in the settings (and the command-line option was the only way of enabling it). It's less useful nowadays. --- Source/Core/DolphinQt/Main.cpp | 2 -- Source/Core/UICommon/CommandLineParse.cpp | 7 +++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/Core/DolphinQt/Main.cpp b/Source/Core/DolphinQt/Main.cpp index 317d12fefa..4b01bdcc27 100644 --- a/Source/Core/DolphinQt/Main.cpp +++ b/Source/Core/DolphinQt/Main.cpp @@ -257,8 +257,6 @@ int main(int argc, char* argv[]) MainWindow win{std::move(boot), static_cast(options.get("movie"))}; Settings::Instance().SetCurrentUserStyle(Settings::Instance().GetCurrentUserStyle()); - if (options.is_set("debugger")) - Settings::Instance().SetDebugModeEnabled(true); win.Show(); #if defined(USE_ANALYTICS) && USE_ANALYTICS diff --git a/Source/Core/UICommon/CommandLineParse.cpp b/Source/Core/UICommon/CommandLineParse.cpp index 54093f219a..a37f0f2561 100644 --- a/Source/Core/UICommon/CommandLineParse.cpp +++ b/Source/Core/UICommon/CommandLineParse.cpp @@ -22,7 +22,7 @@ class CommandLineConfigLayerLoader final : public Config::ConfigLayerLoader { public: CommandLineConfigLayerLoader(const std::list& args, const std::string& video_backend, - const std::string& audio_backend, bool batch) + const std::string& audio_backend, bool batch, bool debugger) : ConfigLayerLoader(Config::LayerType::CommandLine) { if (!video_backend.empty()) @@ -39,6 +39,9 @@ public: if (batch) m_values.emplace_back(Config::MAIN_RENDER_TO_MAIN.GetLocation(), ValueToString(false)); + if (debugger) + m_values.emplace_back(Config::MAIN_ENABLE_DEBUGGING.GetLocation(), ValueToString(true)); + // Arguments are in the format of .
.=Value for (const auto& arg : args) { @@ -134,7 +137,7 @@ static void AddConfigLayer(const optparse::Values& options) Config::AddLayer(std::make_unique( std::move(config_args), static_cast(options.get("video_backend")), static_cast(options.get("audio_emulation")), - static_cast(options.get("batch")))); + static_cast(options.get("batch")), static_cast(options.get("debugger")))); } optparse::Values& ParseArguments(optparse::OptionParser* parser, int argc, char** argv) From 801fa8e905c9ff73c993c940e3e7966e55efc4cb Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Mon, 17 Apr 2023 23:18:42 -0700 Subject: [PATCH 2/2] Only force-show the code widget when first enabling the debugger Before, any call of Settings::SetDebugModeEnabled(true) would show it. This means that if the debugging UI is enabled, but the user manually closed the code widget, then toggling any option on the interface pane (such as "Pause on Focus Loss") would cause the code widget to reappear. Additionally, closing and reopening dolphin did not call SetDebugModeEnabled, so the code widget did not reappear in that case (it only appeared after touching the interface pane). This is a bit silly, so now only enabling the debugger does it. This also somewhat resolves an inconsistency introduced by the previous commit: prior to it, --debugger would call SetDebugModeEnabled(true) and thus show the code pane; after these commits, it does not, as it acts like a config change. This is a behavior difference, but not a particularly important one. --- Source/Core/DolphinQt/Settings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/DolphinQt/Settings.cpp b/Source/Core/DolphinQt/Settings.cpp index bfc2f36ea1..d915f4e916 100644 --- a/Source/Core/DolphinQt/Settings.cpp +++ b/Source/Core/DolphinQt/Settings.cpp @@ -465,9 +465,9 @@ void Settings::SetDebugModeEnabled(bool enabled) { Config::SetBaseOrCurrent(Config::MAIN_ENABLE_DEBUGGING, enabled); emit DebugModeToggled(enabled); + if (enabled) + SetCodeVisible(true); } - if (enabled) - SetCodeVisible(true); } bool Settings::IsDebugModeEnabled() const