Skip to content

Conversation

@nathanpovo
Copy link
Contributor

What kind of change does this PR introduce?

Bug fix.

What is the current behavior?

When a WPF application is shutdown, the Unloaded event is not fired and, as a result, the View is not deactivated by ReactiveUI; as explained in the issue #2490.

What is the new behavior?

The ActivationForViewFetcher will observe the Closing event (if the View is a Window) to determine if the View should be deactivated.

What might this PR break?

Nothing.

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

@dnfadmin
Copy link

dnfadmin commented Jun 15, 2021

CLA assistant check
All CLA requirements met.

@glennawatson
Copy link
Contributor

Thanks, I'll see if I can merge this in tonight for you.

Just noticed the CI server had a software change so need to adapt.

Thanks for the contribution.

@nathanpovo
Copy link
Contributor Author

I have been doing some additional tests with the updated library and just adding an observable base on the Closed event is not enough.

When a ReactiveWindow is closed, the Closed event is fired and the ActivationForViewFetcher informs any observers that the view has been deactivated, as expected.

However, any ReactiveUserControls in that ReactiveWindow (or even a normal Window) will not be deactivated; a ReactiveUserControl is not derived from a Window so it does not have the Closed event, and the Unloaded event is not fired when an application is closing.

nathanpovo and others added 4 commits June 18, 2021 16:46
This tests that both the window and the child control are deactivated when the application is shut down.
When an application is shutdown the Unloaded events are not fired.

Windows have the Closed event that can be used to know that the view should be deactivated. User controls do not have a Closing event so the dispatcher's ShutdownStarted event has to be used instead.
@worldbeater
Copy link
Contributor

Yeah relying on the ShutdownStarted event should work as per https://stackoverflow.com/a/14480184/11351183

nathanpovo and others added 2 commits June 18, 2021 18:01
DistinctUntilChanged is already called on the merged observables.
@glennawatson glennawatson added the release Gets released. label Jun 19, 2021
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release Gets released.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants