Skip to content
Browse files

Disable render to main when using batch mode

This also includes another change: DolphinQt will now exit with an
error if you use --batch without specifying a game using any method
(unlike in the past where --batch would be ignored if you didn't
specify a game using --exec, even if you had used --nand-title).
The main reason why I did this was because coding the alternative
(ignoring --batch) would be annoying with render to main involved.
  • Loading branch information...
JosJuice committed Oct 27, 2019
1 parent 0dbb581 commit 379f264aa8b7dce66f68cf38bfafa57616f3804e
Showing with 28 additions and 4 deletions.
  1. +19 −1 Source/Core/DolphinQt/Main.cpp
  2. +9 −3 Source/Core/UICommon/CommandLineParse.cpp
@@ -138,7 +138,7 @@ int main(int argc, char* argv[])
Settings::Instance().SetBatchModeEnabled(options.is_set("batch") && options.is_set("exec"));

// Hook up alerts from core
@@ -152,12 +152,14 @@ int main(int argc, char* argv[])
&app, &Core::HostDispatchJobs);

std::unique_ptr<BootParameters> boot;
bool game_specified = false;
if (options.is_set("exec"))
const std::list<std::string> paths_list = options.all("exec");
const std::vector<std::string> paths{std::make_move_iterator(std::begin(paths_list)),
boot = BootParameters::GenerateFromFile(paths);
game_specified = true;
else if (options.is_set("nand_title"))
@@ -171,14 +173,30 @@ int main(int argc, char* argv[])
ModalMessageBox::critical(nullptr, QObject::tr("Error"), QObject::tr("Invalid title ID."));
game_specified = true;
else if (!args.empty())
boot = BootParameters::GenerateFromFile(args.front());
game_specified = true;

int retval;

if (Settings::Instance().IsBatchModeEnabled() && !game_specified)
nullptr, QObject::tr("Error"),
QObject::tr("Batch mode cannot be used without specifying a game to launch."));
retval = 1;
else if (Settings::Instance().IsBatchModeEnabled() && !boot)
// A game to launch was specified, but it was invalid.
// An error has already been shown by code above, so exit without showing another error.
retval = 1;

@@ -22,7 +22,7 @@ class CommandLineConfigLayerLoader final : public Config::ConfigLayerLoader
CommandLineConfigLayerLoader(const std::list<std::string>& args, const std::string& video_backend,
const std::string& audio_backend)
const std::string& audio_backend, bool batch)
: ConfigLayerLoader(Config::LayerType::CommandLine)
if (!video_backend.empty())
@@ -31,6 +31,11 @@ class CommandLineConfigLayerLoader final : public Config::ConfigLayerLoader
if (!audio_backend.empty())
m_values.emplace_back(Config::MAIN_DSP_HLE.location, ValueToString(audio_backend == "HLE"));

// Batch mode hides the main window, and render to main hides the render window. To avoid a
// situation where we would have no window at all, disable render to main when using batch mode.
if (batch)
m_values.emplace_back(Config::MAIN_RENDER_TO_MAIN.location, ValueToString(false));

// Arguments are in the format of <System>.<Section>.<Key>=Value
for (const auto& arg : args)
@@ -98,7 +103,7 @@ std::unique_ptr<optparse::OptionParser> CreateParser(ParserOptions options)
parser->add_option("-l", "--logger").action("store_true").help("Open the logger");
parser->add_option("-b", "--batch")
.help("Run Dolphin without the user interface (Requires --exec)");
.help("Run Dolphin without the user interface (Requires --exec or --nand-title)");
parser->add_option("-c", "--confirm").action("store_true").help("Set Confirm on Stop");

@@ -120,7 +125,8 @@ static void AddConfigLayer(const optparse::Values& options)

std::move(config_args), static_cast<const char*>(options.get("video_backend")),
static_cast<const char*>(options.get("audio_emulation"))));
static_cast<const char*>(options.get("audio_emulation")),

optparse::Values& ParseArguments(optparse::OptionParser* parser, int argc, char** argv)

0 comments on commit 379f264

Please sign in to comment.
You can’t perform that action at this time.