I debug for a while, and I found that:
1, if another APP was activate, the C::B will receive a "de-active" event. If currently the Tooltip is the active window, it is the window to receive such event.
2, to handle the event, CCManager try to do these
// cbEVT_APP_DEACTIVATED
void CCManager::OnDeactivateApp(CodeBlocksEvent& event)
{
DoHidePopup();
cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
if (ed)
{
cbStyledTextCtrl* stc = ed->GetControl();
if (stc->CallTipActive())
stc->CallTipCancel();
m_CallTipActive = wxSCI_INVALID_POSITION;
}
event.Skip();
}
Here, in the stc->CallTipCancel();, the window who receive the "de-active" event was destroyed. By internally run a "delete this" of the wxWindow, the wxWindow is totally destroyed.
3, But note the destroy happens in a member function of the wxWindow, which is:
WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
// did we process the message?
bool processed = false;
.....
.....
case WM_KILLFOCUS:
processed = HandleKillFocus((WXHWND)(HWND)wParam);
break;
.....
.....
if ( !processed )
{
#ifdef __WXDEBUG__
wxLogTrace(wxTraceMessages, wxT("Forwarding %s to DefWindowProc."),
wxGetMessageName(message));
#endif // __WXDEBUG__
rc.result = MSWDefWindowProc(message, wParam, lParam);
}
return rc.result;
}
Here, HandleKillFocus() function call return false, so we have a chance to call
rc.result = MSWDefWindowProc(message, wParam, lParam);
Which is actually
rc.result = this->MSWDefWindowProc(message, wParam, lParam);
But "this" is already deleted, so we get a crash here.