summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraristocratos <gnmjpl@gmail.com>2021-09-29 21:24:33 +0200
committeraristocratos <gnmjpl@gmail.com>2021-09-29 21:24:33 +0200
commita246c098cd6ca794b8c6a6680f6c50b22e1b0797 (patch)
tree5bcbe25830b7bd45623c11bf98e5ab204b230a9c
parentcd065cfd83215bc7463157aba5cf88e479a6e6ac (diff)
v1.0.11 Bug fixesv1.0.11
-rw-r--r--CHANGELOG.md10
-rw-r--r--src/btop.cpp29
-rw-r--r--src/btop_tools.cpp1
-rw-r--r--src/btop_tools.hpp8
4 files changed, 26 insertions, 22 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 10532f5..9ec21b0 100644
--- a/CHANGELOG.md
+++ b/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
diff --git a/src/btop.cpp b/src/btop.cpp
index 50a2bba..02ca177 100644
--- a/src/btop.cpp
+++ b/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.");
- }
- 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.");
+ 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()) {
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);
}
diff --git a/src/btop_tools.cpp b/src/btop_tools.cpp
index dc3a0bd..c897b1b 100644
--- a/src/btop_tools.cpp
+++ b/src/btop_tools.cpp
@@ -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) {
diff --git a/src/btop_tools.hpp b/src/btop_tools.hpp
index 7bb0445..97e010a 100644
--- a/src/btop_tools.hpp
+++ b/src/btop_tools.hpp
@@ -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;