Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using destroyed HWND in wxComboPopupWindow #23406

Merged
merged 3 commits into from Apr 1, 2023

Conversation

vadz
Copy link
Contributor

@vadz vadz commented Mar 31, 2023

Destroy wxComboPopupWindow itself if its HWND got destroyed under it as it happened when it was used inside AUI floating pane.

There was no safe way to prevent wxWindow from trying to destroy the
HWND again if it had been already destroyed, for whatever reason, as
UnsubclassWin() asserted if it was called and calling SetHWND(0) before
calling it as some (but not all) existing code did, resulted in not
removing the association using the old HWND as key.

Allow to use DissociateHandle() for safely detaching HWND from the
window, without assuming that it is valid.
Don't call SetHWND(0) before calling UnsubclassWin() to prevent it from
asserting if the HWND was invalid because this prevented the association
with the old HWND from being removed from the global gs_windowHandles
and call DissociateHandle() instead.

Don't call SetHWND(0) after calling UnsubclassWin() because this was
useless, as this function already did this anyhow.
Handle correctly the strange case of the popup window being destroyed
by Windows itself, which happened when the AUI floating frame, which was
used as the parent of the popup when it was created for a wxComboCtrl
inside an AUI pane, was itself destroyed. This resulted in problems
because we kept using popup window even though its HWND wasn't valid any
longer.

Detect when this happens and destroy the popup window too, to force
recreating it when/if it's needed again in the future.

This also requires keeping wxOwnerDrawnComboBox::m_initChs even after
using them, as they will be needed again if we need to recreate the
popup.

Closes wxWidgets#23399.
@vadz vadz merged commit 24a96a7 into wxWidgets:master Apr 1, 2023
36 checks passed
@vadz vadz deleted the combo-danging-popup branch April 1, 2023 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant