Menu ▾ ▴

#64 access violation after press enter in editor control

open
wxsheet (2)
5
2012-12-15
2009-01-13
Thomas
No

Sometimes I get a access violation after press enter in editor control.

I found following code sequence (a simple call stack):
wxwidgets/src/msw/window.cpp:
---
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
// If this has been processed by an event handler, return 0 now
// (we've handled it).
m_lastKeydownProcessed = HandleKeyDown((WORD) wParam, lParam);
---

sheet.cpp:
---
wxSheet::DisableCellEditControl
...
GetSheetRefData()->m_cellEditor.DestroyControl();
---

sheetedt.cpp:
---
wxSheetCellEditorRefData::DestroyControl
...
win->Destroy();
---

The line "win->Destroy" deletes editor object, but is called from "HandleKeyDown".
After "HandleKeyDown" returned, the heap object is destroyed and a assignment to member variable "m_lastKeydownProcessed" happens.
This assignment damages the heap.

my hotfix is:
replace line "win->Destroy();"
by
"wxTheApp->GetTraits()->ScheduleForDestroy(win);"

Discussion


Log in to post a comment.