summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@serenityos.org>2020-06-12 16:26:12 +0300
committerAndreas Kling <kling@serenityos.org>2020-06-12 16:08:45 +0200
commiteb3700c56579e75a3f03892dd2e7344242c78837 (patch)
treea2e9268d54e5313ed844c111c3323b97ef95ea2f /Applications
parent5624f8d8ee33685b2da029701656395fb145722a (diff)
downloadserenity-eb3700c56579e75a3f03892dd2e7344242c78837.zip
Calendar: Fix using OwnPtr<> with RefCounted types
Diffstat (limited to 'Applications')
-rw-r--r--Applications/Calendar/CalendarWidget.cpp8
-rw-r--r--Applications/Calendar/CalendarWidget.h4
-rw-r--r--Applications/Calendar/main.cpp5
3 files changed, 8 insertions, 9 deletions
diff --git a/Applications/Calendar/CalendarWidget.cpp b/Applications/Calendar/CalendarWidget.cpp
index 9d44092a7d..045028107d 100644
--- a/Applications/Calendar/CalendarWidget.cpp
+++ b/Applications/Calendar/CalendarWidget.cpp
@@ -37,7 +37,7 @@
CalendarWidget::CalendarWidget()
{
- m_calendar = make<Calendar>(Core::DateTime::now());
+ m_calendar = adopt(*new Calendar(Core::DateTime::now()));
set_fill_with_background_color(true);
set_layout<GUI::VerticalBoxLayout>();
@@ -196,7 +196,7 @@ void CalendarWidget::update_calendar_tiles(int target_year, int target_month)
void CalendarWidget::show_add_event_window()
{
- AddEventDialog::show(*move(m_calendar), Core::DateTime::now(), window());
+ AddEventDialog::show(m_calendar, Core::DateTime::now(), window());
}
CalendarWidget::CalendarTile::CalendarTile(Calendar& calendar, int index, Core::DateTime date_time)
@@ -230,7 +230,7 @@ void CalendarWidget::CalendarTile::doubleclick_event(GUI::MouseEvent& event)
{
GUI::Widget::doubleclick_event(event);
//TOOD: Should be calling show_add_event_window. Would we just replace m_calender /w m_calender_widget?
- AddEventDialog::show(&m_calendar, m_date_time, window());
+ AddEventDialog::show(m_calendar, m_date_time, window());
}
void CalendarWidget::CalendarTile::paint_event(GUI::PaintEvent& event)
@@ -265,7 +265,7 @@ void CalendarWidget::CalendarTile::paint_event(GUI::PaintEvent& event)
int highlight_rect_width = (font().glyph_width('0') * (m_display_date.length() + 1)) + 2;
auto display_date = (m_date_time.day() == 1 && frame_inner_rect().width() > highlight_rect_width) ? m_display_date : String::number(m_date_time.day());
- if (m_calendar.is_today(m_date_time)) {
+ if (m_calendar->is_today(m_date_time)) {
auto highlight_rect = Gfx::IntRect(day_rect.width() / 2 - (highlight_rect_width / 2), day_rect.y(), highlight_rect_width, font().glyph_height() + 4);
painter.draw_rect(highlight_rect, palette().base_text());
painter.draw_text(day_rect, display_date, Gfx::Font::default_bold_font(), Gfx::TextAlignment::Center, palette().base_text());
diff --git a/Applications/Calendar/CalendarWidget.h b/Applications/Calendar/CalendarWidget.h
index 41c0036c3a..f40d19ad61 100644
--- a/Applications/Calendar/CalendarWidget.h
+++ b/Applications/Calendar/CalendarWidget.h
@@ -45,7 +45,7 @@ private:
void update_calendar_tiles(int target_year, int target_month);
- OwnPtr<Calendar> m_calendar;
+ RefPtr<Calendar> m_calendar;
RefPtr<GUI::Widget> m_top_container;
RefPtr<GUI::Widget> m_bottom_container;
RefPtr<GUI::Label> m_selected_date_label;
@@ -70,7 +70,7 @@ private:
String m_weekday_name;
String m_display_date;
Core::DateTime m_date_time;
- Calendar& m_calendar;
+ RefPtr<Calendar> m_calendar;
};
RefPtr<CalendarTile> m_calendar_tiles[35];
diff --git a/Applications/Calendar/main.cpp b/Applications/Calendar/main.cpp
index 3a0b64ff08..1bbfc13780 100644
--- a/Applications/Calendar/main.cpp
+++ b/Applications/Calendar/main.cpp
@@ -60,8 +60,7 @@ int main(int argc, char** argv)
window->set_title("Calendar");
window->set_rect(20, 200, 596, 475);
- auto calendar_widget = make<CalendarWidget>();
- window->set_main_widget(calendar_widget);
+ auto& calendar_widget = window->set_main_widget<CalendarWidget>();
window->show();
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-calendar.png"));
@@ -70,7 +69,7 @@ int main(int argc, char** argv)
app_menu.add_action(GUI::Action::create("Add Event", { Mod_Ctrl | Mod_Shift, Key_E },
[&](const GUI::Action&) {
- calendar_widget->show_add_event_window();
+ calendar_widget.show_add_event_window();
return;
}));