Skip to content

Commit

Permalink
Fix leak in FragmentContextWrapper by releasing the baseInflator if i…
Browse files Browse the repository at this point in the history
…t exists.

Fixes #2070

RELNOTES=Fix leak in FragmentContextWrapper by releasing the baseInflator if it exists.
PiperOrigin-RevId: 367725173
  • Loading branch information
bcorso authored and Dagger Team committed Apr 9, 2021
1 parent c57ab0a commit 41c4e04
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ private static Context unwrap(Context context, Class<?> target) {
*
* <p>A wrapper class to expose the {@link Fragment} to the views they're inflating.
*/
// This is only non-final for the account override
public static final class FragmentContextWrapper extends ContextWrapper {
private Fragment fragment;
private LayoutInflater baseInflater;
Expand All @@ -181,6 +180,8 @@ public void onStateChanged(LifecycleOwner source, Lifecycle.Event event) {
// Prevent the fragment from leaking if the view outlives the fragment.
// See https://github.com/google/dagger/issues/2070
FragmentContextWrapper.this.fragment = null;
FragmentContextWrapper.this.baseInflater = null;
FragmentContextWrapper.this.inflater = null;
}
}
};
Expand Down

0 comments on commit 41c4e04

Please sign in to comment.