Author Topic: Destructor problem with cbEditor  (Read 3192 times)

Offline 280Z28

  • Regular
  • ***
  • Posts: 397
  • *insert unicode here*
Destructor problem with cbEditor
« on: January 10, 2006, 12:06:33 am »
I connected to an event like this:

Code: [Select]
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:

Code: [Select]
                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:
Code: [Select]
wxString AsCommentsFormatter::ProcessNewLine(const wxString& previous) const
If I replace the second line with this, it works, but I need to modify the line:

Code: [Select]
                wxString newtext = previous;
« Last Edit: January 10, 2006, 12:14:59 am by 280Z28 »
78 280Z, "a few bolt-ons" - 12.71@109.04
99 Trans Am, "Daily Driver" - 525rwhp/475rwtq
 Check out The Sam Zone :cool: