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:
parent
b998f9f02f
commit
85ce138557
@ -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';
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user