diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-05-23 10:59:27 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-05-23 11:04:24 +0100 |
commit | 027c836915deadc901920d84b2718f9617caea0e (patch) | |
tree | 23cc131b67092633d6b65490adb238f13352fdb2 /vcl | |
parent | 5c5209c2d9f2626d2c024493a7f9cde9577e6261 (diff) |
Resolves: rhbz#1338546 use-after-delete of WindowImpl
Change-Id: I528aacd042ff17e6f6cdcd434d1c790b2139928e
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/window/event.cxx | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/vcl/source/window/event.cxx b/vcl/source/window/event.cxx index c7d17778f9cd..aa09c101068c 100644 --- a/vcl/source/window/event.cxx +++ b/vcl/source/window/event.cxx @@ -220,11 +220,14 @@ void Window::CallEventListeners( sal_uLong nEvent, void* pData ) mpWindowImpl->mnEventListenersIteratingCount++; auto& rWindowImpl = *mpWindowImpl; comphelper::ScopeGuard aGuard( - [&rWindowImpl]() + [&rWindowImpl, &xWindow]() { - rWindowImpl.mnEventListenersIteratingCount--; - if (rWindowImpl.mnEventListenersIteratingCount == 0) - rWindowImpl.maEventListenersDeleted.clear(); + if (!xWindow->IsDisposed()) + { + rWindowImpl.mnEventListenersIteratingCount--; + if (rWindowImpl.mnEventListenersIteratingCount == 0) + rWindowImpl.maEventListenersDeleted.clear(); + } } ); for ( Link<VclWindowEvent&,void>& rLink : aCopy ) @@ -250,11 +253,14 @@ void Window::CallEventListeners( sal_uLong nEvent, void* pData ) // we use an iterating counter/flag and a set of deleted Link's to avoid O(n^2) behaviour rWindowImpl.mnChildEventListenersIteratingCount++; comphelper::ScopeGuard aGuard( - [&rWindowImpl]() + [&rWindowImpl, &xWindow]() { - rWindowImpl.mnChildEventListenersIteratingCount--; - if (rWindowImpl.mnChildEventListenersIteratingCount == 0) - rWindowImpl.maChildEventListenersDeleted.clear(); + if (!xWindow->IsDisposed()) + { + rWindowImpl.mnChildEventListenersIteratingCount--; + if (rWindowImpl.mnChildEventListenersIteratingCount == 0) + rWindowImpl.maChildEventListenersDeleted.clear(); + } } ); for ( Link<VclWindowEvent&,void>& rLink : aCopy ) |