signal_emitter: Don't swallow exceptions
If any signal receiver throws an exception for any reason after receiving a signal, no one would find out about it because the signal emitter just ignored exceptions Also actually delivering the signal caused some exceptions because not all signals have a receiver. Resolves #1593
This commit is contained in:
parent
b3ceedde76
commit
b636baf082
1 changed files with 8 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
#include "components/logger.hpp"
|
||||||
#include "events/signal_receiver.hpp"
|
#include "events/signal_receiver.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
@ -25,12 +26,15 @@ class signal_emitter {
|
||||||
template <typename Signal>
|
template <typename Signal>
|
||||||
bool emit(const Signal& sig) {
|
bool emit(const Signal& sig) {
|
||||||
try {
|
try {
|
||||||
for (auto&& item : g_signal_receivers.at(id<Signal>())) {
|
if (g_signal_receivers.find(id<Signal>()) != g_signal_receivers.end()) {
|
||||||
if (item.second->on(sig)) {
|
for (auto&& item : g_signal_receivers.at(id<Signal>())) {
|
||||||
return true;
|
if (item.second->on(sig)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (const std::exception& e) {
|
||||||
|
logger::make().err(e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue