Skip to content

Commit

Permalink
fix: memory leak (#124)
Browse files Browse the repository at this point in the history
Fix memory leak where Window.Closed events never where un-registered.

Closes #122
  • Loading branch information
FantasticFiasco authored Aug 27, 2020
1 parent b2501ca commit d67c593
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ NOTE: Features with breaking changes are found on branch [releases/v8](https://g
### :syringe: Fixed

- Specify dependency groups in nuspec for each supported framework version
- [#122](https://github.com/FantasticFiasco/mvvm-dialogs/issues/122) Fix memory leak where `Window.Closed` events never where un-registered (discovered by [@peter-durrant](https://github.com/peter-durrant))

## 7.1.0 - 2020-06-07

Expand Down
5 changes: 4 additions & 1 deletion src/net/DialogServiceViews.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ internal static void Register(IView view)

PruneInternalViews();

// Register for owner window closing, since we then should unregister view reference
// Register for owner window closing to cleanup views connected to this window, but
// only register for the event once, thus the un-registration of any prior
// registrations.
owner.Closed -= OwnerClosed;
owner.Closed += OwnerClosed;

Logger.Write($"Register view {view.Id}");
Expand Down

0 comments on commit d67c593

Please sign in to comment.