Skip to content

Commit

Permalink
fix(calendarview): fixed potential NRE when unloaded before being ful…
Browse files Browse the repository at this point in the history
…ly initialized
  • Loading branch information
carldebilly committed Jun 7, 2021
1 parent 6149f9b commit 34657f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -703,15 +703,15 @@ internal void AttachVisibleIndicesUpdatedEvent()

internal void DetachVisibleIndicesUpdatedEvent()
{
if (m_epVisibleIndicesUpdatedHandler is {})
if (m_epVisibleIndicesUpdatedHandler is {} && m_tpPanel is {})
{
m_tpPanel.VisibleIndicesUpdated -= m_epVisibleIndicesUpdatedHandler;
}
}

internal void AttachScrollViewerFocusEngagedEvent()
{
if (m_tpPanel is { })
if (m_tpPanel is { } && m_tpScrollViewer is { })
{
ScrollViewer sv = (m_tpScrollViewer as ScrollViewer);
m_epScrollViewerFocusEngagedEventHandler ??= new ControlFocusEngagedEventCallback(
Expand All @@ -728,7 +728,7 @@ internal void AttachScrollViewerFocusEngagedEvent()

internal void DetachScrollViewerFocusEngagedEvent()
{
if (m_epScrollViewerFocusEngagedEventHandler is {})
if (m_epScrollViewerFocusEngagedEventHandler is {} && m_tpScrollViewer is {})
{
m_tpScrollViewer.FocusEngaged -= m_epScrollViewerFocusEngagedEventHandler;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1251,15 +1251,15 @@ private void AttachButtonClickedEvents()

private void DetachButtonClickedEvents()
{
if (m_epHeaderButtonClickHandler is { })
if (m_epHeaderButtonClickHandler is { } && m_tpHeaderButton is {})
{
m_tpHeaderButton.Click -= m_epHeaderButtonClickHandler;
}
if (m_epPreviousButtonClickHandler is {})
if (m_epPreviousButtonClickHandler is {} && m_tpPreviousButton is {})
{
m_tpPreviousButton.Click -= m_epPreviousButtonClickHandler;
}
if (m_epNextButtonClickHandler is {})
if (m_epNextButtonClickHandler is {} && m_tpNextButton is {})
{
m_tpNextButton.Click -= m_epNextButtonClickHandler;
}
Expand Down

0 comments on commit 34657f0

Please sign in to comment.