From ad0d16e243270257e14d69e5938417efd9e59bca Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 9 Jan 2021 12:02:33 +1000 Subject: [PATCH] Qt: Fix failing to load unicode filenames on command line --- src/duckstation-qt/main.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/duckstation-qt/main.cpp b/src/duckstation-qt/main.cpp index b190f80b1..6831abf24 100644 --- a/src/duckstation-qt/main.cpp +++ b/src/duckstation-qt/main.cpp @@ -7,6 +7,24 @@ #include #include +static bool ParseCommandLineParameters(QApplication& app, QtHostInterface* host_interface, + std::unique_ptr* boot_params) +{ + const QStringList args(app.arguments()); + std::vector converted_args; + std::vector converted_argv; + converted_args.reserve(args.size()); + converted_argv.reserve(args.size()); + + for (const QString& arg : args) + converted_args.push_back(arg.toStdString()); + + for (std::string& arg : converted_args) + converted_argv.push_back(arg.data()); + + return host_interface->ParseCommandLineParameters(args.size(), converted_argv.data(), boot_params); +} + int main(int argc, char* argv[]) { // Register any standard types we need elsewhere @@ -29,7 +47,7 @@ int main(int argc, char* argv[]) std::unique_ptr host_interface = std::make_unique(); std::unique_ptr boot_params; - if (!host_interface->ParseCommandLineParameters(argc, argv, &boot_params)) + if (!ParseCommandLineParameters(app, host_interface.get(), &boot_params)) return EXIT_FAILURE; std::unique_ptr window = std::make_unique(host_interface.get());