For the record, this function is only called by the thread that
created it.
I decided to check out this function using DevPartner's Error
Detection tool, and it occasionally triggers a 'Overrun detected'
error during the call to 'AppendText'. Details of the error simply
point to 'riched20.dll'. What character is being appended (or how
many) does not appear to matter, the fault occurs seemingly randomly.
Putting two and two together, an overflow of some sort could explain
the application crashes, as well as why they aren't consistent or
reproducible.
Questions:
1. Is there anything wrong with the code below? Note that I'm using
VS2005 with /clr:oldSyntax.
2. Does anyone know of any issues along these lines in riched20.dll?
Googling shows a number of issues, but none that seem relevant.
Any suggestions would be greatly appreciated.
Ryan
void myDialog::OutputMessage(const std::string& message) {
String* str = message.c_str();
Drawing::Font* boldFont = new Drawing::Font(S"Monospac821 BT", 9.25F,
System::Drawing::FontStyle::Bold,
System::Drawing::GraphicsUnit::Point, (System::Byte)0);
Drawing::Font* regularFont = m_outputWindow->get_Font();
// Set the default font and color
m_outputWindow->set_SelectionFont(regularFont);
m_outputWindow->set_SelectionColor(Drawing::Color::Black);
// Parse through the characters looking for font formating
for (int ii = 0; ii != str->get_Length(); ++ii) {
__wchar_t currChar = str->get_Chars(ii);
// Parse for font options, setting boldFont or regularFont
appropriately
// ... clipped for brevity
// Append the character
String* curStr = new String(currChar, 1);
m_outputWindow->AppendText(curStr); // this line triggers
DevPartner ErrorDetection
}
m_outputWindow->AppendText(S"\r\n");
// scroll along with our message(s)
m_outputWindow->set_SelectionStart(m_outputWindow->get_Text()-
>get_Length());
m_outputWindow->Focus();
m_outputWindow->ScrollToCaret();
}