Bug 1516423 - Clean up MessageData holding TaskbarWindowPreview when it's destroyed. r=cmartin

When `TaskbarWindowPreview` is constructed, it registers its adress in `WindowHook`
as a listener.  However, when an instance of `TaskbarWindowPreview` is destroyed,
it does not remove all listeners.  This emerges as Thunderbird's crash because TB
creates `TaskbarWindowPreview` to show a tray icon but the instance is accidentally
freed when the icon is still active due to another bug.  As a result, TB crashes
when `TaskbarPreview::MainWindowHook` tries to access a freed `TaskbarWindowPreview`
to handle a click on the icon.

This patch adds a call to `SetVisible(false)` in `TaskbarWindowPreview`'s dtor to
clean up the things.  This will stop the crash in TB, but TB's taskbar icon still
does not behave correctly because it accidentally disappears without crash.
We need an additional patch to fix it.

Differential Revision: https://phabricator.services.mozilla.com/D109720
This commit is contained in:
Toshihito Kikuchi 2021-04-01 00:32:27 +00:00
parent 0414682ea1
commit 5a07f6187c

View File

@ -66,6 +66,9 @@ TaskbarWindowPreview::~TaskbarWindowPreview() {
mOverlayIcon = nullptr;
}
// We need to clean up a hook associated with the "this" pointer.
SetVisible(false);
if (IsWindowAvailable()) {
DetachFromNSWindow();
} else {