Skip to content

Commit ae88af4

Browse files
committed
Fixed lifetime issue with connection and match
1 parent b946ef2 commit ae88af4

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

exes/ttui/src/dbus_screen_manager.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,13 @@ void DBusScreenManager::SetupComponents() {
4747
}
4848

4949
void DBusScreenManager::SetupDBusConnection() {
50-
auto connection = std::make_shared<sdbusplus::asio::connection>(ctx, tfc::dbus::sd_bus_open_system_mon());
51-
auto match = std::make_unique<sdbusplus::bus::match::match>(
52-
*connection,
53-
"",
54-
std::bind(&DBusScreenManager::match_callback, this, std::placeholders::_1)
55-
);
50+
connection =
51+
std::make_shared<sdbusplus::asio::connection>(ctx, tfc::dbus::sd_bus_open_system_mon());
52+
match = std::make_unique<sdbusplus::bus::match::match>(
53+
*connection,
54+
"",
55+
[this](sdbusplus::message_t& msg) { this->match_callback(msg); }
56+
);
5657
auto mc = connection->new_method_call("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus.Monitoring",
5758
"BecomeMonitor");
5859
mc.append<std::vector<std::string>, uint32_t>({ "path=/com/skaginn3x/Signals" }, 0);
@@ -96,7 +97,7 @@ void DBusScreenManager::match_callback(sdbusplus::message_t& msg) {
9697
}
9798
}
9899

99-
ftxui::Component DBusScreenManager::left_menu() {
100+
auto DBusScreenManager::left_menu() -> ftxui::Component {
100101
auto option = ftxui::MenuOption::Vertical();
101102

102103
option.on_enter = [this] {
@@ -109,8 +110,8 @@ ftxui::Component DBusScreenManager::left_menu() {
109110
return ftxui::Menu(&noticed_interfaces, &left_menu_selected, option);
110111
}
111112

112-
ftxui::Component DBusScreenManager::right_menu() {
113+
auto DBusScreenManager::right_menu() -> ftxui::Component {
113114
auto option = ftxui::MenuOption::Vertical();
114-
option.on_enter = screen.ExitLoopClosure();
115+
// option.on_enter = screen.ExitLoopClosure();
115116
return ftxui::Menu(&entries, &right_menu_selected, option);
116117
}

exes/ttui/src/dbus_screen_manager.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class DBusScreenManager {
3434
int left_menu_selected = 0;
3535
int right_menu_selected = 0;
3636
asio::io_context ctx{};
37+
std::shared_ptr<sdbusplus::asio::connection> connection;
38+
std::__detail::__unique_ptr_t<sdbusplus::bus::match::match> match;
3739

3840
void SetupComponents();
3941
void SetupDBusConnection();

0 commit comments

Comments
 (0)