refactor: try/catch, sigc trackable

This commit is contained in:
Alex
2019-05-13 15:15:50 +02:00
parent 0c3c548bc0
commit 362c393b1d
7 changed files with 21 additions and 16 deletions

View File

@ -14,11 +14,6 @@ Watcher::Watcher()
watcher_(sn_watcher_skeleton_new()) {}
Watcher::~Watcher() {
if (bus_name_id_ != 0) {
Gio::DBus::unown_name(bus_name_id_);
bus_name_id_ = 0;
}
if (hosts_ != nullptr) {
g_slist_free_full(hosts_, gfWatchFree);
hosts_ = nullptr;

View File

@ -19,7 +19,13 @@ Workspaces::Workspaces(const std::string &id, const Bar &bar, const Json::Value
worker();
}
void Workspaces::onEvent(const struct Ipc::ipc_response &res) { ipc_.sendCmd(IPC_GET_WORKSPACES); }
void Workspaces::onEvent(const struct Ipc::ipc_response &res) {
try {
ipc_.sendCmd(IPC_GET_WORKSPACES);
} catch (const std::exception &e) {
std::cerr << "Workspaces: " << e.what() << std::endl;
}
}
void Workspaces::onCmd(const struct Ipc::ipc_response &res) {
if (res.type == IPC_GET_WORKSPACES) {
@ -194,7 +200,11 @@ bool Workspaces::handleScroll(GdkEventScroll *e) {
return false;
}
}
ipc_.sendCmd(IPC_COMMAND, fmt::format("workspace \"{}\"", name));
try {
ipc_.sendCmd(IPC_COMMAND, fmt::format("workspace \"{}\"", name));
} catch (const std::exception &e) {
std::cerr << "Workspaces: " << e.what() << std::endl;
}
return true;
}