mirror of https://github.com/aristocratos/btop.git
Fixed UTF-8 check to include UTF8 and added thread started check before joining in clean_quit()
This commit is contained in:
parent
3b80ef9e40
commit
fca1d8c199
12
src/btop.cpp
12
src/btop.cpp
|
@ -80,6 +80,7 @@ namespace Global {
|
||||||
|
|
||||||
atomic<bool> resized (false);
|
atomic<bool> resized (false);
|
||||||
atomic<bool> quitting (false);
|
atomic<bool> quitting (false);
|
||||||
|
atomic<bool> _runner_started (false);
|
||||||
|
|
||||||
bool arg_tty = false;
|
bool arg_tty = false;
|
||||||
bool arg_low_color = false;
|
bool arg_low_color = false;
|
||||||
|
@ -184,7 +185,7 @@ void clean_quit(int sig) {
|
||||||
if (Global::quitting) return;
|
if (Global::quitting) return;
|
||||||
Global::quitting = true;
|
Global::quitting = true;
|
||||||
Runner::stop();
|
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!");
|
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
|
//? 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 (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(lang).ends_with("UTF-8")) {
|
if (const string lang = (string)getenv("LANG"); str_to_upper(s_replace(lang, "-", "")).ends_with("UTF8")) {
|
||||||
found = true;
|
found = true;
|
||||||
std::setlocale(LC_ALL, lang.c_str());
|
std::setlocale(LC_ALL, lang.c_str());
|
||||||
}
|
}
|
||||||
else if (const string loc = std::locale("").name(); not loc.empty()) {
|
else if (const string loc = std::locale("").name(); not loc.empty()) {
|
||||||
try {
|
try {
|
||||||
for (auto& l : ssplit(loc, ';')) {
|
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;
|
found = true;
|
||||||
std::setlocale(LC_ALL, l.substr(l.find('=') + 1).c_str());
|
std::setlocale(LC_ALL, l.substr(l.find('=') + 1).c_str());
|
||||||
break;
|
break;
|
||||||
|
@ -766,6 +767,9 @@ int main(int argc, char **argv) {
|
||||||
Global::exit_error_msg = "Failed to create _runner thread!";
|
Global::exit_error_msg = "Failed to create _runner thread!";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Global::_runner_started = true;
|
||||||
|
}
|
||||||
|
|
||||||
//? Calculate sizes of all boxes
|
//? Calculate sizes of all boxes
|
||||||
Config::presetsValid(Config::getS("presets"));
|
Config::presetsValid(Config::getS("presets"));
|
||||||
|
|
Loading…
Reference in New Issue