Skip to content

fix: Check Intptr and HwndSource isn't Zero before using in TitleBar#1447

Merged
pomianowski merged 1 commit intolepoco:mainfrom
jbryknar:main
Jun 11, 2025
Merged

fix: Check Intptr and HwndSource isn't Zero before using in TitleBar#1447
pomianowski merged 1 commit intolepoco:mainfrom
jbryknar:main

Conversation

@jbryknar
Copy link
Copy Markdown
Collaborator

@jbryknar jbryknar commented Jun 10, 2025

Pull request type

Please check the type of change your PR introduces:

  • Update
  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes

What is the current behavior?

  • When the user holds down the ESC key while a message box is open, the application crashes.
  • Rapidly closing the window immediately after it appears leads to an “HWND = 0” error.
  • In contrast, explicitly setting the window’s content to null does not cause a crash.

453433093-6d004393-65b6-41ef-971b-30a97d0d92d3

Issue Number: #1383

What is the new behavior?

  • Before interacting with a window, the code now verifies that the HWND value is non-zero, preventing invalid handle usage.
  • When attaching hooks, it first confirms that the HwndSource instance is not null, ensuring it only adds hooks to valid sources.
  • As a result, holding ESC key or rapidly closing the message box no longer triggers crashes or “HWND = 0” errors.

MessageBox_RapidCloseAction

@jbryknar jbryknar requested a review from pomianowski as a code owner June 10, 2025 11:25
@github-actions github-actions bot added controls Changes to the appearance or logic of custom controls. PR Pull request dotnet release titlebar Titlebar updates labels Jun 10, 2025
@pomianowski pomianowski changed the title Check Intptr and HwndSource isn't Zero before using in TitleBar fix: Check Intptr and HwndSource isn't Zero before using in TitleBar Jun 11, 2025
@pomianowski pomianowski merged commit ddba528 into lepoco:main Jun 11, 2025
2 checks passed
@pomianowski pomianowski linked an issue Jun 11, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

controls Changes to the appearance or logic of custom controls. dotnet PR Pull request release titlebar Titlebar updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hold keyboard esc open messagebox window crash

2 participants