Skip to content

Commit

Permalink
resolve TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
igagis committed Sep 10, 2024
1 parent 150b20f commit b101c08
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/bedsidemon/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once

#include <tml/tree.hpp>

#include <utki/signal.hpp>
#include <utki/singleton.hpp>

namespace bedsidemon {

Expand All @@ -32,7 +32,7 @@ struct settings {
uint32_t sweep_speed_um_per_sec = default_sweep_speed_um_per_sec;
};

class settings_storage
class settings_storage : public utki::singleton<settings_storage>
{
std::string filename;

Expand Down
4 changes: 2 additions & 2 deletions src/bedsidemon/settings_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,14 @@ settings_menu::settings_menu(utki::shared_ref<ruis::context> context) :
ASSERT(sb.get_selection() < sweep_speeds_um_per_sec.size())
auto speed = sweep_speeds_um_per_sec[sb.get_selection()];

auto& ss = bedsidemon::application::inst().settings_storage;
auto& ss = settings_storage::inst();

auto s = ss.get();
s.sweep_speed_um_per_sec = speed;
ss.set(s);
};

auto& ss = bedsidemon::application::inst().settings_storage;
auto& ss = settings_storage::inst();
const auto& s = ss.get();
auto i = std::find(
sweep_speeds_um_per_sec.begin(), //
Expand Down
20 changes: 12 additions & 8 deletions src/bedsidemon/spo2/spo2_parameter_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ spo2_parameter_window::spo2_parameter_window(utki::shared_ref<ruis::context> con
}
))
{
auto& ss = bedsidemon::application::inst().settings_storage;
auto& ss = settings_storage::inst();
decltype(settings_storage::settings_changed_signal
)::callback_type settings_change_handler = [&pw = *this](const settings& s) {
pw.waveform.set_sweep_speed(ruis::real(s.sweep_speed_um_per_sec) / ruis::real(std::milli::den));
Expand All @@ -244,13 +244,17 @@ spo2_parameter_window::spo2_parameter_window(utki::shared_ref<ruis::context> con
this->settings_change_signal_connection = ss.settings_changed_signal.connect(std::move(settings_change_handler));
}

spo2_parameter_window::~spo2_parameter_window() = default;

// {
// TODO: disconnect settings change observer
// auto& ss = bedsidemon::application::inst().settings_storage;
// ss.settings_changed_signal.disconnect(this->settings_change_signal_connection);
// }
spo2_parameter_window::~spo2_parameter_window()
{
// in case of application exit, the parameter window widgets will be destroyed by
// ruisapp::application::gui destructor, which is after the settings_storage,
// so we need to check if the settings_storage object still exists before
// disconnecting from its signal
if (settings_storage::is_created()) {
auto& ss = settings_storage::inst();
ss.settings_changed_signal.disconnect(this->settings_change_signal_connection);
}
}

void spo2_parameter_window::set(const spo2_measurement& meas)
{
Expand Down

0 comments on commit b101c08

Please sign in to comment.