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

Crash in wxAUI/wxOverlay on Mac when tabs/windows are dragged #24415

Closed
dkulp opened this issue Mar 19, 2024 · 3 comments
Closed

Crash in wxAUI/wxOverlay on Mac when tabs/windows are dragged #24415

dkulp opened this issue Mar 19, 2024 · 3 comments
Labels
regression Worked previously, doesn't work any longer
Milestone

Comments

@dkulp
Copy link
Contributor

dkulp commented Mar 19, 2024

Description

With the recent changes to use wxOverlay, we're seeing a bunch of crashes and other issues when dragging/docking windows with wxAUI on the Mac. This can be seen with the wxAUI sample with a debug build of wxWidgets. If you start the sample and immediately try to drag one of the tabs off the notebook, an assert is raised and then the app crashes.

Screenshot 2024-03-18 at 9 51 57 PM

MacOS Sonoma 14.4, Xcode 15

@vadz
Copy link
Contributor

vadz commented Mar 19, 2024

Thanks, I can reproduce this and AFAICS this happens because m_overlayWindow is null, i.e. either wxOverlayImpl::CreateOverlayWindow() hadn't been called, somehow, or it failed. But I don't immediately see why would this happen...

cc @AliKet

@vadz vadz added this to the 3.3.0 milestone Mar 19, 2024
@vadz vadz added the regression Worked previously, doesn't work any longer label Mar 19, 2024
@dkulp
Copy link
Contributor Author

dkulp commented Mar 23, 2024

I BELIEVE this can be fixed via:

--- a/src/osx/cocoa/overlay.mm
+++ b/src/osx/cocoa/overlay.mm
@@ -280,7 +280,7 @@ void wxOverlayImpl::Clear(wxDC* dc)

 void wxOverlayImpl::Reset()
 {
-    if ( m_window )
+    if ( m_window && m_overlayWindow)
     {
         // erase whatever was drawn on the overlay the last time
         wxClientDC dc(m_window);

It seems to occur when you try to drag the tab (or AUI frame) over something that shouldn't accept the tab/frame in which case there wouldn't be an overlay for it. Thus, there would be nothing to clear/reset.

@vadz
Copy link
Contributor

vadz commented Mar 24, 2024

Thanks! I agree that Reset() shouldn't do anything in this case, so I'm pushing a commit with the same effect, with which I can't reproduce the bug any more. Please let me know if you still see any problems.

@vadz vadz closed this as completed in 613a4c4 Mar 24, 2024
DoctorNoobingstoneIPresume pushed a commit to DoctorNoobingstoneIPresume/wxWidgets_wxWidgets that referenced this issue Mar 25, 2024
It is valid to call Reset() even if Init() had never been called, e.g.
when we didn't need to draw anything on the overlay, but it asserted and
crashed in this case because it used invalid m_overlayWindow under Mac.

Fix this by simply doing nothing in Reset() if m_overlayWindow was not
initialized.

This commit is best viewed ignoring whitespace-only changes.

Closes wxWidgets#24415.

Co-Authored-By: Daniel Kulp <dan@kulp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression Worked previously, doesn't work any longer
Projects
None yet
Development

No branches or pull requests

2 participants