Only trigger async once eventloop has been setup
This commit is contained in:
parent
2c7af2a60c
commit
6d3bb2211e
@ -105,6 +105,11 @@ class controller : public signal_receiver<SIGN_PRIORITY_CONTROLLER, signals::eve
|
||||
|
||||
std::unique_ptr<eventloop> eloop;
|
||||
|
||||
/**
|
||||
* Once this is set to true, 'eloop' and any uv handles can be used.
|
||||
*/
|
||||
std::atomic_bool m_eloop_ready{false};
|
||||
|
||||
/**
|
||||
* \brief Async handle to notify the eventloop
|
||||
*
|
||||
|
@ -153,14 +153,13 @@ void controller::trigger_update(bool force) {
|
||||
m_notifications.update = true;
|
||||
m_notifications.force_update = m_notifications.force_update || force;
|
||||
|
||||
// TODO this isn't really safe
|
||||
if (m_notifier) {
|
||||
trigger_notification();
|
||||
}
|
||||
}
|
||||
|
||||
void controller::trigger_notification() {
|
||||
if (m_eloop_ready) {
|
||||
UV(uv_async_send, m_notifier.get());
|
||||
}
|
||||
}
|
||||
|
||||
void controller::stop(bool reload) {
|
||||
@ -285,8 +284,6 @@ void controller::read_events(bool confwatch) {
|
||||
m_bar->start();
|
||||
}
|
||||
|
||||
process_update(true);
|
||||
|
||||
auto ipc_handle = std::unique_ptr<uv_pipe_t>(nullptr);
|
||||
auto screenshot_timer_handle = std::unique_ptr<uv_timer_t>(nullptr);
|
||||
|
||||
@ -326,6 +323,13 @@ void controller::read_events(bool confwatch) {
|
||||
UV(uv_timer_start, screenshot_timer_handle.get(), screenshot_cb_wrapper, 3000, 0);
|
||||
}
|
||||
|
||||
m_eloop_ready.store(true);
|
||||
|
||||
/*
|
||||
* Immediately trigger and update so that the bar displays something.
|
||||
*/
|
||||
trigger_update(true);
|
||||
|
||||
eloop->run();
|
||||
} catch (const exception& err) {
|
||||
m_log.err("Fatal Error in eventloop: %s", err.what());
|
||||
|
Loading…
Reference in New Issue
Block a user