I connected to an event like this:
void AutoStyle::OnEditorOpened(CodeBlocksEvent& event)
{
if ( !m_IsAttached )
{
event.Skip();
return;
}
cbEditor* ed = EDMAN()->GetBuiltinEditor( event.GetEditor() );
if ( ed )
{
ed->Connect( wxEVT_SCI_CHARADDED,
(wxObjectEventFunction) (wxEventFunction) (wxScintillaEventFunction)
&AutoStyle::OnEditorCharAdded );
}
event.Skip();
}
In AutoStyle::OnEditorCharAdded, I have the following two lines:
wxString previous = ed->GetControl()->GetLine(currLine-1);
wxString newtext = cmt_formatter->ProcessNewLine(previous);
While running in the debugger, when I "step into" ProcessNewLine(), it takes me to ~cbEditor(), destroys the editor, and segfaults :shock:
Here is the declaration for it:
wxString AsCommentsFormatter::ProcessNewLine(const wxString& previous) const
If I replace the second line with this, it works, but I need to modify the line:
wxString newtext = previous;