Opened 13 years ago

Last modified 13 years ago

#4271 closed defect

wxAuiNotebook causes access violations upon tab deletion

Reported by: tibosoft Owned by: biwillia76
Priority: normal Milestone:
Component: wxAui Version:
Keywords: Cc: tibosoft, biwillia76
Blocked By: Blocking:
Patch: no

Description

(Using wxWidgets-2.8.4, WinXP, VS 2003)

In a wxAuiNotebook, when you close a tab by clicking the close button, the EVT_LEFT_UP event is caught by the wxAuiTabCtrl that owns the button.

It fires a wxEVT_COMMAND_AUINOTEBOOK_BUTTON. This is processed immediately by the parent wxAuiNotebook. If the close is accepted, the notebook deletes the page. The control goes back to the wxTabCtrl::OnLeftUp() function, which executes 4 statements:

m_pressed_button = NULL;
m_click_pt = wxDefaultPosition;
m_is_dragging = false;
m_click_tab = NULL;

which are all erroneous since the `this' pointer has been deleted and is not valid anymore.

I have found a fix for this by adding a member variable to the wxAuiNotebookEvent that can be set to true by the notebook to indicate that a page has been deleted. If so, the tab ctrl handler can return immediately, thus skipping the invalid statements.

The fix does work and eliminates the errors as reported by Purify (see attachment) - and the nasty random bugs that would result from those hidden access violations.

Attachments (1)

wxAuiNotebook_bug_Purify_report.txt download (4.6 KB) - added by tibosoft 13 years ago.
IBM Rational Purify report showing the error

Download all attachments as: .zip

Change History (6)

Changed 13 years ago by tibosoft

IBM Rational Purify report showing the error

comment:1 Changed 13 years ago by biwillia76

Hi there,

Can you please check this against the 2.8 branch? I think we might have already fixed it.

Thanks,
Ben

comment:2 Changed 13 years ago by tibosoft

Hi

I guess you mean 2.9 branch :) Anyway I tried with the latest SVN and even though I did not have a chance - yet - to try it with Purify, it seems that the bug is gone. Seems that the wxAuiTabCtrl deletion is deferred now, and does not cause the access violations anymore.
I'll confirm this as soon as I can run my program with Purify.

Thanks

Thibault

comment:3 Changed 13 years ago by biwillia76

Hi,

Thanks for checking. I've applied these patches in parallel in the 2.8 branch (which will become 2.8.5) and trunk. This means that, if the problem is fixed in the trunk, then you will also not encounter this problem in 2.8.5

All the best,
Ben

comment:4 Changed 13 years ago by tibosoft

Hi

After a full range of checks, I am now sure that the bug is gone with the latest SVN trunk, so I guess we can close this bug.
I'm looking forward to seeing 2.8.5 out !

Thank you
Thibault

comment:5 Changed 13 years ago by biwillia76

This bug has been fixed.

Note: See TracTickets for help on using tickets.