mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
fix(thread): check before detach
This commit is contained in:
parent
9a1b8bb831
commit
d0933ab50f
@ -74,7 +74,9 @@ struct SleeperThread {
|
|||||||
{
|
{
|
||||||
do_run_ = false;
|
do_run_ = false;
|
||||||
condvar_.notify_all();
|
condvar_.notify_all();
|
||||||
thread_.detach();
|
if (thread_.joinable()) {
|
||||||
|
thread_.detach();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
#include "client.hpp"
|
#include "client.hpp"
|
||||||
|
|
||||||
waybar::Client::Client(int argc, char* argv[])
|
waybar::Client::Client(int argc, char* argv[])
|
||||||
: gtk_app(Gtk::Application::create(argc, argv, "org.alexays.waybar")),
|
: gtk_app(Gtk::Application::create(argc, argv, "fr.arouillard.waybar")),
|
||||||
gdk_display(Gdk::Display::get_default()),
|
gdk_display(Gdk::Display::get_default())
|
||||||
wl_display(gdk_wayland_display_get_wl_display(gdk_display->gobj()))
|
|
||||||
{
|
{
|
||||||
|
if (!gdk_display) {
|
||||||
|
throw std::runtime_error("Can't find display");
|
||||||
|
}
|
||||||
|
if (!GDK_IS_WAYLAND_DISPLAY(gdk_display->gobj())) {
|
||||||
|
throw std::runtime_error("Bar need to run under Wayland");
|
||||||
|
}
|
||||||
|
wl_display = gdk_wayland_display_get_wl_display(gdk_display->gobj());
|
||||||
auto getFirstValidPath = [] (std::vector<std::string> possiblePaths) {
|
auto getFirstValidPath = [] (std::vector<std::string> possiblePaths) {
|
||||||
wordexp_t p;
|
wordexp_t p;
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ int waybar::modules::sway::Ipc::open(const std::string& socketPath) const
|
|||||||
addr.sun_path[sizeof(addr.sun_path) - 1] = 0;
|
addr.sun_path[sizeof(addr.sun_path) - 1] = 0;
|
||||||
int l = sizeof(struct sockaddr_un);
|
int l = sizeof(struct sockaddr_un);
|
||||||
if (::connect(fd, reinterpret_cast<struct sockaddr *>(&addr), l) == -1) {
|
if (::connect(fd, reinterpret_cast<struct sockaddr *>(&addr), l) == -1) {
|
||||||
throw std::runtime_error("Unable to connect to " + socketPath);
|
throw std::runtime_error("Unable to connect to Sway");
|
||||||
}
|
}
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user