Fixed UTF-8 check to include UTF8 and added thread started check before joining in clean_quit()

This commit is contained in:
aristocratos 2021-09-18 17:59:45 +02:00
parent 3b80ef9e40
commit fca1d8c199

View file

@ -80,6 +80,7 @@ namespace Global {
atomic<bool> resized (false);
atomic<bool> quitting (false);
atomic<bool> _runner_started (false);
bool arg_tty = false;
bool arg_low_color = false;
@ -184,7 +185,7 @@ void clean_quit(int sig) {
if (Global::quitting) return;
Global::quitting = true;
Runner::stop();
if (pthread_join(Runner::runner_id, NULL) != 0) {
if (Global::_runner_started and pthread_join(Runner::runner_id, NULL) != 0) {
Logger::error("Failed to join _runner thread!");
}
@ -703,15 +704,15 @@ int main(int argc, char **argv) {
}
//? Try to find and set a UTF-8 locale
if (bool found = false; not str_to_upper((string)std::setlocale(LC_ALL, NULL)).ends_with("UTF-8")) {
if (const string lang = (string)getenv("LANG"); str_to_upper(lang).ends_with("UTF-8")) {
if (bool found = false; not str_to_upper(s_replace(string(std::setlocale(LC_ALL, NULL)), "-", "")).ends_with("UTF8")) {
if (const string lang = (string)getenv("LANG"); str_to_upper(s_replace(lang, "-", "")).ends_with("UTF8")) {
found = true;
std::setlocale(LC_ALL, lang.c_str());
}
else if (const string loc = std::locale("").name(); not loc.empty()) {
try {
for (auto& l : ssplit(loc, ';')) {
if (str_to_upper(l).ends_with("UTF-8")) {
if (str_to_upper(s_replace(l, "-", "")).ends_with("UTF8")) {
found = true;
std::setlocale(LC_ALL, l.substr(l.find('=') + 1).c_str());
break;
@ -766,6 +767,9 @@ int main(int argc, char **argv) {
Global::exit_error_msg = "Failed to create _runner thread!";
exit(1);
}
else {
Global::_runner_started = true;
}
//? Calculate sizes of all boxes
Config::presetsValid(Config::getS("presets"));