mirror of
https://github.com/aristocratos/btop.git
synced 2024-09-28 22:21:35 +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
|
## v1.0.10
|
||||||
|
|
||||||
* Added: Wait for terminal size properties to be available at start
|
* Added: Wait for terminal size properties to be available at start
|
||||||
|
29
src/btop.cpp
29
src/btop.cpp
@ -55,7 +55,7 @@ namespace Global {
|
|||||||
{"#801414", "██████╔╝ ██║ ╚██████╔╝██║ ╚═╝ ╚═╝"},
|
{"#801414", "██████╔╝ ██║ ╚██████╔╝██║ ╚═╝ ╚═╝"},
|
||||||
{"#000000", "╚═════╝ ╚═╝ ╚═════╝ ╚═╝"},
|
{"#000000", "╚═════╝ ╚═╝ ╚═════╝ ╚═╝"},
|
||||||
};
|
};
|
||||||
const string Version = "1.0.10";
|
const string Version = "1.0.11";
|
||||||
|
|
||||||
int coreCount;
|
int coreCount;
|
||||||
string overlay;
|
string overlay;
|
||||||
@ -712,20 +712,21 @@ 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 (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, ""));
|
Logger::debug("Using locale " + (string)std::setlocale(LC_ALL, ""));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
string found;
|
string found;
|
||||||
if (std::getenv("LANG") != NULL and str_to_upper(s_replace((string)std::getenv("LANG"), "-", "")).ends_with("UTF8")) {
|
bool set_failure = false;
|
||||||
found = std::getenv("LANG");
|
for (const auto loc_env : array{"LANG", "LC_ALL"}) {
|
||||||
if (std::setlocale(LC_ALL, std::getenv("LANG")) == NULL)
|
if (std::getenv(loc_env) != NULL and str_to_upper(s_replace((string)std::getenv(loc_env), "-", "")).ends_with("UTF8")) {
|
||||||
Logger::warning("Failed to set locale " + (string)std::getenv("LANG") + " continuing anyway.");
|
found = std::getenv(loc_env);
|
||||||
}
|
if (std::setlocale(LC_ALL, found.c_str()) == NULL) {
|
||||||
if (found.empty() and std::getenv("LC_ALL") != NULL and str_to_upper(s_replace((string)std::getenv("LC_ALL"), "-", "")).ends_with("UTF8")) {
|
set_failure = true;
|
||||||
found = std::getenv("LC_ALL");
|
Logger::warning("Failed to set locale " + found + " continuing anyway.");
|
||||||
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 (found.empty()) {
|
||||||
if (setenv("LC_ALL", "", 1) == 0 and setenv("LANG", "", 1) == 0) {
|
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 != "*") {
|
if (const auto loc = std::locale("").name(); not loc.empty() and loc != "*") {
|
||||||
for (auto& l : ssplit(loc, ';')) {
|
for (auto& l : ssplit(loc, ';')) {
|
||||||
if (str_to_upper(s_replace(l, "-", "")).ends_with("UTF8")) {
|
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.substr(l.find('=') + 1);
|
||||||
found = l;
|
if (std::setlocale(LC_ALL, found.c_str()) != NULL) {
|
||||||
break;
|
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.";
|
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);
|
clean_quit(1);
|
||||||
}
|
}
|
||||||
else
|
else if (not set_failure)
|
||||||
Logger::debug("Setting LC_ALL=" + found);
|
Logger::debug("Setting LC_ALL=" + found);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +329,6 @@ namespace Tools {
|
|||||||
atomic_lock::~atomic_lock() {
|
atomic_lock::~atomic_lock() {
|
||||||
active_locks--;
|
active_locks--;
|
||||||
this->atom.store(false);
|
this->atom.store(false);
|
||||||
atomic_notify(this->atom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string readfile(const std::filesystem::path& path, const string& fallback) {
|
string readfile(const std::filesystem::path& path, const string& fallback) {
|
||||||
|
@ -269,15 +269,9 @@ namespace Tools {
|
|||||||
string hostname();
|
string hostname();
|
||||||
string username();
|
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_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 {
|
class atomic_lock {
|
||||||
atomic<bool>& atom;
|
atomic<bool>& atom;
|
||||||
bool not_true = false;
|
bool not_true = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user