Skip to content

Commit

Permalink
[Merge M100] Fix NPE when dismissing messages on tab destruction
Browse files Browse the repository at this point in the history
The MessageDispatcher can be null if the activity is being recreated or
destroyed. The other methods in MessageDispatcherBridge null check the
MessageDispatcher before calling any methods, so we should also do this
for dismissMessage(). Note that all messages get dismissed when
detaching the MessageDispatcher from WindowAndroid.

(cherry picked from commit a92ab84)

Bug: 1304262
Change-Id: Idd263ff6d0561b8eb064f73ec06daeb0af427e97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3509779
Reviewed-by: Matthew Jones <mdjones@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#978788}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3514545
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Clark DuVall <cduvall@chromium.org>
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/branch-heads/4896@{#420}
Cr-Branched-From: 1f63ff4-refs/heads/main@{#972766}
  • Loading branch information
clarkduvall authored and Chromium LUCI CQ committed Mar 9, 2022
1 parent a79106f commit 89d4972
Showing 1 changed file with 1 addition and 0 deletions.
Expand Up @@ -43,6 +43,7 @@ private static boolean enqueueWindowScopedMessage(
private static void dismissMessage(
MessageWrapper message, WindowAndroid windowAndroid, @DismissReason int dismissReason) {
MessageDispatcher messageDispatcher = MessageDispatcherProvider.from(windowAndroid);
if (messageDispatcher == null) return;
messageDispatcher.dismissMessage(message.getMessageProperties(), dismissReason);
}
}

0 comments on commit 89d4972

Please sign in to comment.