mirror of
https://github.com/aristocratos/btop.git
synced 2024-09-27 22:01:29 +02:00
v1.0.11 Bug fixes
This commit is contained in:
parent
cd065cfd83
commit
a246c098cd
10
CHANGELOG.md
10
CHANGELOG.md
@ -1,3 +1,13 @@
|
||||
## v1.0.11
|
||||
|
||||
* Changed: atomic_wait to use while loop instead of wait() because of rare stall when a signal handler is triggered while waiting
|
||||
|
||||
* Fixed: Get real / mountpoint when running inside snap
|
||||
|
||||
* Fixed: UTF8 set LANG and LC_ALL to empty before UTF8 search and fixed empty error msg on exit before signal handler init
|
||||
|
||||
* Changed: Init will continue with a warning if UTF-8 locale are detected and it fails to set the locale
|
||||
|
||||
## v1.0.10
|
||||
|
||||
* Added: Wait for terminal size properties to be available at start
|
||||
|
27
src/btop.cpp
27
src/btop.cpp
@ -55,7 +55,7 @@ namespace Global {
|
||||
{"#801414", "██████╔╝ ██║ ╚██████╔╝██║ ╚═╝ ╚═╝"},
|
||||
{"#000000", "╚═════╝ ╚═╝ ╚═════╝ ╚═╝"},
|
||||
};
|
||||
const string Version = "1.0.10";
|
||||
const string Version = "1.0.11";
|
||||
|
||||
int coreCount;
|
||||
string overlay;
|
||||
@ -712,20 +712,21 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
//? Try to find and set a UTF-8 locale
|
||||
if (std::setlocale(LC_ALL, "") != NULL and str_to_upper(s_replace((string)std::setlocale(LC_ALL, ""), "-", "")).ends_with("UTF8")) {
|
||||
if (std::setlocale(LC_ALL, "") != NULL and not s_contains((string)std::setlocale(LC_ALL, ""), ";")
|
||||
and str_to_upper(s_replace((string)std::setlocale(LC_ALL, ""), "-", "")).ends_with("UTF8")) {
|
||||
Logger::debug("Using locale " + (string)std::setlocale(LC_ALL, ""));
|
||||
}
|
||||
else {
|
||||
string found;
|
||||
if (std::getenv("LANG") != NULL and str_to_upper(s_replace((string)std::getenv("LANG"), "-", "")).ends_with("UTF8")) {
|
||||
found = std::getenv("LANG");
|
||||
if (std::setlocale(LC_ALL, std::getenv("LANG")) == NULL)
|
||||
Logger::warning("Failed to set locale " + (string)std::getenv("LANG") + " continuing anyway.");
|
||||
bool set_failure = false;
|
||||
for (const auto loc_env : array{"LANG", "LC_ALL"}) {
|
||||
if (std::getenv(loc_env) != NULL and str_to_upper(s_replace((string)std::getenv(loc_env), "-", "")).ends_with("UTF8")) {
|
||||
found = std::getenv(loc_env);
|
||||
if (std::setlocale(LC_ALL, found.c_str()) == NULL) {
|
||||
set_failure = true;
|
||||
Logger::warning("Failed to set locale " + found + " continuing anyway.");
|
||||
}
|
||||
}
|
||||
if (found.empty() and std::getenv("LC_ALL") != NULL and str_to_upper(s_replace((string)std::getenv("LC_ALL"), "-", "")).ends_with("UTF8")) {
|
||||
found = std::getenv("LC_ALL");
|
||||
if (std::setlocale(LC_ALL, std::getenv("LC_ALL")) == NULL)
|
||||
Logger::warning("Failed to set locale " + (string)std::getenv("LC_ALL") + " continuing anyway.");
|
||||
}
|
||||
if (found.empty()) {
|
||||
if (setenv("LC_ALL", "", 1) == 0 and setenv("LANG", "", 1) == 0) {
|
||||
@ -733,8 +734,8 @@ int main(int argc, char **argv) {
|
||||
if (const auto loc = std::locale("").name(); not loc.empty() and loc != "*") {
|
||||
for (auto& l : ssplit(loc, ';')) {
|
||||
if (str_to_upper(s_replace(l, "-", "")).ends_with("UTF8")) {
|
||||
if (std::setlocale(LC_ALL, l.substr(l.find('=') + 1).c_str()) != NULL) {
|
||||
found = l;
|
||||
found = l.substr(l.find('=') + 1);
|
||||
if (std::setlocale(LC_ALL, found.c_str()) != NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -751,7 +752,7 @@ int main(int argc, char **argv) {
|
||||
Global::exit_error_msg = "No UTF-8 locale detected!\nUse --utf-force argument to force start if you're sure your terminal can handle it.";
|
||||
clean_quit(1);
|
||||
}
|
||||
else
|
||||
else if (not set_failure)
|
||||
Logger::debug("Setting LC_ALL=" + found);
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,6 @@ namespace Tools {
|
||||
atomic_lock::~atomic_lock() {
|
||||
active_locks--;
|
||||
this->atom.store(false);
|
||||
atomic_notify(this->atom);
|
||||
}
|
||||
|
||||
string readfile(const std::filesystem::path& path, const string& fallback) {
|
||||
|
@ -269,15 +269,9 @@ namespace Tools {
|
||||
string hostname();
|
||||
string username();
|
||||
|
||||
// #if __GNUC__ < 11
|
||||
inline void atomic_wait(const atomic<bool>& atom, const bool old=true) noexcept { while (atom.load() == old) sleep_ms(1); }
|
||||
inline void atomic_notify(const atomic<bool>& atom) noexcept { (void)atom; }
|
||||
// #else
|
||||
// inline void atomic_wait(const atomic<bool>& atom, const bool old=true) noexcept { if (atom == old) atom.wait(old); }
|
||||
// inline void atomic_notify(const atomic<bool>& atom) noexcept { atom.notify_all(); }
|
||||
// #endif
|
||||
|
||||
//* Waits for atomic<bool> to be false and sets it to true on construct, sets to false and notifies on destruct
|
||||
//* Waits for atomic<bool> to be false and sets it to true on construct, sets to false on destruct
|
||||
class atomic_lock {
|
||||
atomic<bool>& atom;
|
||||
bool not_true = false;
|
||||
|
Loading…
Reference in New Issue
Block a user