mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Merge pull request #578 from alebastr/ipc-use-after-free
fix(sway): resolve destruction dependency between Ipc and SleeperThread
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include "ipc.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
namespace waybar::modules::sway {
|
||||
|
||||
@ -28,6 +29,7 @@ class Ipc {
|
||||
void sendCmd(uint32_t type, const std::string &payload = "");
|
||||
void subscribe(const std::string &payload);
|
||||
void handleEvent();
|
||||
void setWorker(std::function<void()> &&func);
|
||||
|
||||
protected:
|
||||
static inline const std::string ipc_magic_ = "i3-ipc";
|
||||
@ -38,9 +40,10 @@ class Ipc {
|
||||
struct ipc_response send(int fd, uint32_t type, const std::string &payload = "");
|
||||
struct ipc_response recv(int fd);
|
||||
|
||||
int fd_;
|
||||
int fd_event_;
|
||||
std::mutex mutex_;
|
||||
int fd_;
|
||||
int fd_event_;
|
||||
std::mutex mutex_;
|
||||
util::SleeperThread thread_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::sway
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "client.hpp"
|
||||
#include "modules/sway/ipc/client.hpp"
|
||||
#include "util/json.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
namespace waybar::modules::sway {
|
||||
|
||||
@ -18,14 +17,11 @@ class Mode : public ALabel, public sigc::trackable {
|
||||
|
||||
private:
|
||||
void onEvent(const struct Ipc::ipc_response&);
|
||||
void worker();
|
||||
|
||||
std::string mode_;
|
||||
util::JsonParser parser_;
|
||||
std::mutex mutex_;
|
||||
|
||||
util::SleeperThread thread_;
|
||||
Ipc ipc_;
|
||||
Ipc ipc_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::sway
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "client.hpp"
|
||||
#include "modules/sway/ipc/client.hpp"
|
||||
#include "util/json.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
namespace waybar::modules::sway {
|
||||
|
||||
@ -20,7 +19,6 @@ class Window : public ALabel, public sigc::trackable {
|
||||
private:
|
||||
void onEvent(const struct Ipc::ipc_response&);
|
||||
void onCmd(const struct Ipc::ipc_response&);
|
||||
void worker();
|
||||
std::tuple<std::size_t, int, std::string, std::string> getFocusedNode(const Json::Value& nodes,
|
||||
std::string& output);
|
||||
void getTree();
|
||||
@ -33,9 +31,7 @@ class Window : public ALabel, public sigc::trackable {
|
||||
std::size_t app_nb_;
|
||||
util::JsonParser parser_;
|
||||
std::mutex mutex_;
|
||||
|
||||
util::SleeperThread thread_;
|
||||
Ipc ipc_;
|
||||
Ipc ipc_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::sway
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "client.hpp"
|
||||
#include "modules/sway/ipc/client.hpp"
|
||||
#include "util/json.hpp"
|
||||
#include "util/sleeper_thread.hpp"
|
||||
|
||||
namespace waybar::modules::sway {
|
||||
|
||||
@ -21,7 +20,6 @@ class Workspaces : public AModule, public sigc::trackable {
|
||||
private:
|
||||
void onCmd(const struct Ipc::ipc_response&);
|
||||
void onEvent(const struct Ipc::ipc_response&);
|
||||
void worker();
|
||||
bool filterButtons();
|
||||
Gtk::Button& addButton(const Json::Value&);
|
||||
void onButtonReady(const Json::Value&, Gtk::Button&);
|
||||
@ -38,9 +36,7 @@ class Workspaces : public AModule, public sigc::trackable {
|
||||
util::JsonParser parser_;
|
||||
std::unordered_map<std::string, Gtk::Button> buttons_;
|
||||
std::mutex mutex_;
|
||||
|
||||
util::SleeperThread thread_;
|
||||
Ipc ipc_;
|
||||
Ipc ipc_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::sway
|
||||
|
Reference in New Issue
Block a user