From 381985afbb955c6303a565fe823470dc15eeb66b Mon Sep 17 00:00:00 2001 From: Jeremy Borgman Date: Sun, 14 Feb 2021 19:45:03 -0600 Subject: [PATCH] Handle exception when locales are not properly configured --- src/utils/filenamehandler.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/utils/filenamehandler.cpp b/src/utils/filenamehandler.cpp index 22119bac..928a7849 100644 --- a/src/utils/filenamehandler.cpp +++ b/src/utils/filenamehandler.cpp @@ -20,12 +20,23 @@ #include #include #include +#include #include +#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG +#include "spdlog/cfg/env.h" +#include "spdlog/spdlog.h" + FileNameHandler::FileNameHandler(QObject* parent) : QObject(parent) { - std::locale::global(std::locale("")); + try { + std::locale::global(std::locale("")); + } catch (std::exception& e) { + spdlog::error("Locales on your system are not properly configured. " + "Falling back to defaults"); + std::locale::global(std::locale("en_US.UTF-8")); + } } QString FileNameHandler::parsedPattern()