From 1d2c6aeb773122dfe54079f703134d9e9c21f1d7 Mon Sep 17 00:00:00 2001 From: Hugo Amiard Date: Sat, 8 Apr 2023 19:10:27 +0200 Subject: [PATCH] Platform: don't crash EmscriptenApplication on a WebGL-less build. The code right below is querying the `log` option, which wasn't added. Becomes a problem when Magnum is compiled w/o GL support, e.g. for a custom WebGPU renderer. --- src/Magnum/Platform/EmscriptenApplication.cpp | 6 +++++- src/Magnum/Platform/GlfwApplication.cpp | 5 +++-- src/Magnum/Platform/Sdl2Application.cpp | 5 +++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Magnum/Platform/EmscriptenApplication.cpp b/src/Magnum/Platform/EmscriptenApplication.cpp index 48b0587c6..e678ddb8b 100644 --- a/src/Magnum/Platform/EmscriptenApplication.cpp +++ b/src/Magnum/Platform/EmscriptenApplication.cpp @@ -238,7 +238,11 @@ EmscriptenApplication::EmscriptenApplication(const Arguments& arguments, NoCreat #ifdef MAGNUM_TARGET_GL _context.emplace(NoCreate, args, arguments.argc, arguments.argv); #else - args.parse(arguments.argc, arguments.argv); + /** @todo this is duplicated here, in Sdl2Application and in + GlfwApplication, figure out a nice non-duplicated way to handle this */ + args.addOption("log", "default").setHelp("log", "console logging", "default|quiet|verbose") + .setFromEnvironment("log") + .parse(arguments.argc, arguments.argv); #endif /* Save command-line arguments */ diff --git a/src/Magnum/Platform/GlfwApplication.cpp b/src/Magnum/Platform/GlfwApplication.cpp index 55da5ad12..e7d90d8b5 100644 --- a/src/Magnum/Platform/GlfwApplication.cpp +++ b/src/Magnum/Platform/GlfwApplication.cpp @@ -81,8 +81,9 @@ GlfwApplication::GlfwApplication(const Arguments& arguments, NoCreateT): #ifdef MAGNUM_TARGET_GL _context.emplace(NoCreate, args, arguments.argc, arguments.argv); #else - /** @todo this is duplicated here and in Sdl2Application, figure out a nice - non-duplicated way to handle this */ + /** @todo this is duplicated here, in Sdl2Application and in + EmscriptenApplication, figure out a nice non-duplicated way to handle + this */ args.addOption("log", "default").setHelp("log", "console logging", "default|quiet|verbose") .setFromEnvironment("log") .parse(arguments.argc, arguments.argv); diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index 57b0d8b7f..6010e3c5e 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -126,8 +126,9 @@ Sdl2Application::Sdl2Application(const Arguments& arguments, NoCreateT): #ifdef MAGNUM_TARGET_GL _context.emplace(NoCreate, args, arguments.argc, arguments.argv); #else - /** @todo this is duplicated here and in GlfwApplication, figure out a nice - non-duplicated way to handle this */ + /** @todo this is duplicated here, in GlfwApplication and in + EmscriptenApplication, figure out a nice non-duplicated way to handle + this */ args.addOption("log", "default").setHelp("log", "console logging", "default|quiet|verbose") .setFromEnvironment("log") .parse(arguments.argc, arguments.argv);