Commit 9e6c6aa9 authored by Finnur Thorarinsson's avatar Finnur Thorarinsson Committed by Commit Bot

Android PhotoPicker: Fix crash.

Earlier I fixed a crash in updateSelectionState by
returning early. That, however, isn't enough because
onSelectionState also calls isPictureTile, when it
is not safe to do so (because initialize hasn't been
called).

A better way is to move the early return up one
function in the callstack (from updateSelectionState
to onSelectionState), which should catch both of these
issues.

To be sure, I also checked if updateSelectionState could
be called outside of onSelectionState and found two variants:
1) It is called after initialize (when it is safe).
2) It is called after we call isPictureTile (e.g. in setChecked),
in which case we would already be seeing crash stacks for
that (but we're not).

Bug: 760785, 656015
Change-Id: I0f200b16cd34698e103dc4c2b07b3f86c948adad
Reviewed-on: https://chromium-review.googlesource.com/892886
Commit-Queue: Theresa <twellington@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532887}
parent a348d7d8
......@@ -144,6 +144,13 @@ public class PickerBitmapView extends SelectableItemView<PickerBitmap> {
@Override
public void onSelectionStateChange(List<PickerBitmap> selectedItems) {
// If the user cancels the dialog before this object has initialized,
// the SelectionDelegate will try to notify us that all selections have
// been cleared. However, we don't need to process that message and, in
// fact, we can't do so because isPictureTile relies on mBitmapDetails
// being initialized.
if (mBitmapDetails == null) return;
updateSelectionState();
if (!isPictureTile()) return;
......@@ -327,14 +334,6 @@ public class PickerBitmapView extends SelectableItemView<PickerBitmap> {
* Updates the selection controls for this view.
*/
private void updateSelectionState() {
// If the user cancels the dialog before this object has initialized,
// the SelectionDelegate will try to notify us that all selections have
// been cleared. However, we don't need to process that message and, in
// fact, we can't do so because isPictureTile relies on mBitmapDetails
// being initialized.
if (mBitmapDetails == null)
return;
boolean special = !isPictureTile();
boolean checked = super.isChecked();
boolean anySelection =
......
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