Ticket #12981 (closed defect: duplicate)
Attempt to display wxRichTextFormattingDialog leads to a crash
|Reported by:||PB||Owned by:|
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, ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, _T("0"), wxDefaultPosition, 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.