From 340230f6bf8358e1764bd9748464baf27e4f85e7 Mon Sep 17 00:00:00 2001 From: 0GreenClover0 Date: Sun, 13 Aug 2023 20:49:34 +0200 Subject: [PATCH] Calendar: Promote view_type ActionGroup to CalendarWidget's member Otherwise, it would get destroyed after exiting the create() function. --- Userland/Applications/Calendar/CalendarWidget.cpp | 9 +++++---- Userland/Applications/Calendar/CalendarWidget.h | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Userland/Applications/Calendar/CalendarWidget.cpp b/Userland/Applications/Calendar/CalendarWidget.cpp index 48baf2fecd..4777679019 100644 --- a/Userland/Applications/Calendar/CalendarWidget.cpp +++ b/Userland/Applications/Calendar/CalendarWidget.cpp @@ -49,11 +49,12 @@ ErrorOr> CalendarWidget::create(GUI::Window* paren view_month_action->set_checked(true); auto view_year_action = TRY(widget->create_view_year_action()); - auto view_type_action_group = make(); - view_type_action_group->set_exclusive(true); - view_type_action_group->add_action(*view_month_action); - view_type_action_group->add_action(*view_year_action); + widget->m_view_type_action_group = make(); + widget->m_view_type_action_group->set_exclusive(true); + widget->m_view_type_action_group->add_action(*view_month_action); + widget->m_view_type_action_group->add_action(*view_year_action); + auto default_view = Config::read_string("Calendar"sv, "View"sv, "DefaultView"sv, "Month"sv); if (default_view == "Year") view_year_action->set_checked(true); diff --git a/Userland/Applications/Calendar/CalendarWidget.h b/Userland/Applications/Calendar/CalendarWidget.h index 4659928cea..383542535e 100644 --- a/Userland/Applications/Calendar/CalendarWidget.h +++ b/Userland/Applications/Calendar/CalendarWidget.h @@ -42,6 +42,8 @@ private: ErrorOr> create_view_year_action(); ErrorOr> create_open_settings_action(); + OwnPtr m_view_type_action_group; + RefPtr m_event_calendar; };