Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

Destructor problem with cbEditor

(1/1)

280Z28:
I connected to an event like this:


--- Code: ---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();
}

--- End code ---

In AutoStyle::OnEditorCharAdded, I have the following two lines:


--- Code: ---                wxString previous = ed->GetControl()->GetLine(currLine-1);
                wxString newtext = cmt_formatter->ProcessNewLine(previous);

--- End code ---

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:

--- Code: ---wxString AsCommentsFormatter::ProcessNewLine(const wxString& previous) const
--- End code ---

If I replace the second line with this, it works, but I need to modify the line:


--- Code: ---                wxString newtext = previous;
--- End code ---

Navigation

[0] Message Index

Go to full version