Opened 7 years ago

Closed 7 years ago

#12981 closed defect (duplicate)

Attempt to display wxRichTextFormattingDialog leads to a crash

Reported by: PB Owned by:
Priority: normal Milestone:
Component: wxRichText Version: stable-latest
Keywords: wxRichTextFormattingDialog Cc:
Blocked By: Blocking:
Patch: no


When you attempt to invoke wxRichTextFormattingDialog, the application crashes. You can easily reproduce this with richtext sample. Launch the sample, select few characters (necessary to enable a menu command) and choose Format/Paragraph... from the menu. Boom.

wxRichTextBulletsPage::UpdatePreview() is called before m_previewCtrl is created, so its m_previewCtrl->GetFont() inevitable leads to the crash since m_previewCtrl is NULL. I stepped through the code and learnt that wxRichTextBulletsPage::UpdatePreview() is called before wxRichTextBulletsPage::CreateControls() has finished. UpdatePreview() is called by wxRichTextBulletsPage::OnNumberctrlTextUpdated(), which seems to be triggered by this line (\src\richtext\richtextbulletspage.cpp:266) in wxRichTextBulletsPage::CreateControls():

m_numberCtrl = new wxSpinCtrl( itemRichTextDialogPage1, 
    wxSize(50, -1), wxSP_ARROW_KEYS, 0, 100000, 0 );

It looks like creating the spin control (or its buddy?) generates an update message, so this might be MSW specific issue. It seems that the simplest solution would be to just return from UpdatePreview() without doing anything if m_previewCtrl is NULL, but this might lead to some side effects, if the UpdatePreview() is not called from elsewhere before displaying the dialog/page. But this could be avoided by explicitly calling UpdatePreview() from CreateControls() once we are sure all controls have been created. I'm not familiar with wxRichText framework at all, so I won't dig any deeper / offer a real solution, sorry.

By the way, for whatever it's worth, it works as expected in 2.91.

Change History (2)

comment:1 Changed 7 years ago by roberthoffmann


I think the reason for the crash is the same as I described as number 3 in #12941, cured by rtcsrc2.patch.



comment:2 Changed 7 years ago by PB

  • Resolution set to duplicate
  • Status changed from new to closed

Ah, my bad. At the time I searched the trac for a similar bug report, I didn't know the reason for crash yet, so I failed to relate it to your ticket.

Closing the ticket because it's a duplicate of an issue 3 reported in #12491.

Note: See TracTickets for help on using tickets.