Skip to content

Commit

Permalink
Fix calendar going into update loop
Browse files Browse the repository at this point in the history
  • Loading branch information
tari01 committed Jul 26, 2020
1 parent d754849 commit e7f2629
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/datetime/actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Actions

virtual void set_location(const std::string& zone, const std::string& name)=0;

void set_calendar_date(const DateTime&);
void set_calendar_date(const DateTime&, bool bUpdateCalendar);
GActionGroup* action_group();
const std::shared_ptr<State> state() const;

Expand Down
12 changes: 8 additions & 4 deletions src/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void on_calendar_active_changed(GSimpleAction * /*action*/,
{
auto self = static_cast<Actions*>(gself);

self->set_calendar_date(self->state()->clock->localtime());
self->set_calendar_date(self->state()->clock->localtime(), true);
}
}

Expand All @@ -143,7 +143,7 @@ void on_calendar_activated(GSimpleAction * /*action*/,
g_return_if_fail(t != 0);

auto dt = DateTime::Local(t).start_of_day();
static_cast<Actions*>(gself)->set_calendar_date(dt);
static_cast<Actions*>(gself)->set_calendar_date(dt, false);
}

GVariant* create_default_header_state()
Expand Down Expand Up @@ -272,9 +272,13 @@ void Actions::update_calendar_state()
create_calendar_state(m_state));
}

void Actions::set_calendar_date(const DateTime& date)
void Actions::set_calendar_date(const DateTime& date, bool bUpdateCalendar)
{
m_state->calendar_month->month().set(date);
if (bUpdateCalendar)
{
m_state->calendar_month->month().set(date);
}

m_state->calendar_upcoming->date().set(date);
}

Expand Down

0 comments on commit e7f2629

Please sign in to comment.