Kaydet (Commit) aa87af58 authored tarafından Philippe Jung's avatar Philippe Jung Kaydeden (comit) Michael Meeks

tdf#91081 Fix LO crash after dialog closing by ESC

When control is no longuer valid, skip emission of
notification - chaining to the parent

When opening a popup dialog by right click and immediately
pressing ESC immediately, LO crashes.

A focus event listener is still registered. It triggers an event on a
component previously freed.

Change-Id: Icfc941849be5d50e2477d4e92afff844f76892d8
üst ca35b597
...@@ -253,33 +253,36 @@ OUString Control::GetDisplayText() const ...@@ -253,33 +253,36 @@ OUString Control::GetDisplayText() const
bool Control::Notify( NotifyEvent& rNEvt ) bool Control::Notify( NotifyEvent& rNEvt )
{ {
if ( rNEvt.GetType() == MouseNotifyEvent::GETFOCUS ) // tdf#91081 if control is not valid, skip the emission - chaining to the parent
{ if (mpControlData)
if ( !mbHasControlFocus )
{
mbHasControlFocus = true;
StateChanged( StateChangedType::CONTROL_FOCUS );
if ( ImplCallEventListenersAndHandler( VCLEVENT_CONTROL_GETFOCUS, maGetFocusHdl, this ) )
// been destroyed within the handler
return true;
}
}
else
{ {
if ( rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS ) if ( rNEvt.GetType() == MouseNotifyEvent::GETFOCUS )
{ {
vcl::Window* pFocusWin = Application::GetFocusWindow(); if ( !mbHasControlFocus )
if ( !pFocusWin || !ImplIsWindowOrChild( pFocusWin ) )
{ {
mbHasControlFocus = false; mbHasControlFocus = true;
StateChanged( StateChangedType::CONTROL_FOCUS ); StateChanged( StateChangedType::CONTROL_FOCUS );
if ( ImplCallEventListenersAndHandler( VCLEVENT_CONTROL_LOSEFOCUS, maLoseFocusHdl, this ) ) if ( ImplCallEventListenersAndHandler( VCLEVENT_CONTROL_GETFOCUS, maGetFocusHdl, this ) )
// been destroyed within the handler // been destroyed within the handler
return true; return true;
} }
} }
else
{
if ( rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS )
{
vcl::Window* pFocusWin = Application::GetFocusWindow();
if ( !pFocusWin || !ImplIsWindowOrChild( pFocusWin ) )
{
mbHasControlFocus = false;
StateChanged( StateChangedType::CONTROL_FOCUS );
if ( ImplCallEventListenersAndHandler( VCLEVENT_CONTROL_LOSEFOCUS, maLoseFocusHdl, this ) )
// been destroyed within the handler
return true;
}
}
}
} }
return Window::Notify( rNEvt ); return Window::Notify( rNEvt );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment