Skip to content

Fixed issue when view is hidden and then re-shown - #183

Merged
Paul Dumais (pauldumais) merged 1 commit into
masterfrom
avalonia-activation
Aug 20, 2026
Merged

Fixed issue when view is hidden and then re-shown#183
Paul Dumais (pauldumais) merged 1 commit into
masterfrom
avalonia-activation

Conversation

@pauldumais

Copy link
Copy Markdown
Contributor

This pull request improves how RdpClientView manages the lifecycle of its native control handle, especially when the control is temporarily detached (such as during docking or tab operations). The changes ensure that the native control (HWND) is not destroyed prematurely and is properly released when the view is disposed. The tests are updated to verify this new behavior.

Improvements to native control lifecycle management:

  • Added a detachedNativeControl field to RdpClientView to retain the HWND when the control is detached but not disposed, preventing premature destruction during docking or tab detachment scenarios.
  • Modified DestroyNativeControlCore to retain the native control in detachedNativeControl if the view is not disposed, and only destroy it when the view is explicitly disposed.
  • Updated CreateNativeControlCore to reuse the retained detachedNativeControl when reattaching, ensuring the existing session is preserved instead of creating a new one.
  • Updated Dispose to explicitly destroy the retained native control if it exists, ensuring proper cleanup when the view is disposed.

Test coverage enhancements:

  • Added tests in AvaloniaHosting.cs to verify that RdpClientView properly reuses a detached native control and correctly destroys it upon disposal, preventing resource leaks or premature destruction.

@pauldumais
Paul Dumais (pauldumais) requested review from Marc-André Moreau (mamoreau-devolutions) and a balanced review from Copilot and removed request for Copilot August 20, 2026 11:36
@pauldumais
Paul Dumais (pauldumais) merged commit 25ed752 into master Aug 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant