StyledEdit: Fix #10349.

Override QuitRequested in FindWindow to notify the parent edit window of the
find window's demise so it can reset its corresponding pointer. Otherwise the
latter will potentially access the invalid pointer in question on subsequent
find requests, leading to potential crashes.
This commit is contained in:
Rene Gollent 2013-12-28 22:03:03 -05:00
parent b998f9f02f
commit 85ce138557
4 changed files with 17 additions and 0 deletions

View File

@ -43,6 +43,7 @@ const uint32 MSG_SEARCH = 'msea';
const uint32 MSG_REPLACE = 'msre';
const uint32 MSG_REPLACE_ALL = 'mrea';
const uint32 MSG_HIDE_WINDOW = 'mhdw';
const uint32 MSG_FIND_WINDOW_QUIT = 'mfwq';
// "Font"-menu
const uint32 FONT_SIZE = 'FMsi';

View File

@ -110,6 +110,16 @@ FindWindow::DispatchMessage(BMessage* message, BHandler* handler)
}
bool
FindWindow::QuitRequested()
{
BMessenger messenger(fHandler);
messenger.SendMessage(MSG_FIND_WINDOW_QUIT);
return true;
}
void
FindWindow::Show()
{

View File

@ -26,6 +26,7 @@ class FindWindow : public BWindow {
virtual void MessageReceived(BMessage* message);
virtual void DispatchMessage(BMessage* message, BHandler* handler);
virtual bool QuitRequested();
virtual void Show();
private:

View File

@ -254,6 +254,11 @@ StyledEditWindow::MessageReceived(BMessage* message)
fFindWindow->Activate();
break;
}
case MSG_FIND_WINDOW_QUIT:
{
fFindWindow = NULL;
break;
}
case MSG_SEARCH:
message->FindString("findtext", &fStringToFind);
fFindAgainItem->SetEnabled(true);