Qt: Fix failing to load unicode filenames on command line

This commit is contained in:
Connor McLaughlin 2021-01-09 12:02:33 +10:00
parent 64fc560314
commit ad0d16e243

View file

@ -7,6 +7,24 @@
#include <cstdlib>
#include <memory>
static bool ParseCommandLineParameters(QApplication& app, QtHostInterface* host_interface,
std::unique_ptr<SystemBootParameters>* boot_params)
{
const QStringList args(app.arguments());
std::vector<std::string> converted_args;
std::vector<char*> 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<QtHostInterface> host_interface = std::make_unique<QtHostInterface>();
std::unique_ptr<SystemBootParameters> boot_params;
if (!host_interface->ParseCommandLineParameters(argc, argv, &boot_params))
if (!ParseCommandLineParameters(app, host_interface.get(), &boot_params))
return EXIT_FAILURE;
std::unique_ptr<MainWindow> window = std::make_unique<MainWindow>(host_interface.get());