mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 1257667 - Try to catch stale cursor usage using LeakCanary r=sebastian
The ordering in this commit is now correct, whereas the previously pushed commit hadn't addressed the review comment. MozReview-Commit-ID: Ga5lPgwpIxp --HG-- extra : source : ca8d1e1caeefdcd45bd608adec7a10c3632ceab5 extra : amend_source : 39a2ef44130138eb664d4af679ffe49433749de7
This commit is contained in:
parent
51bde91b05
commit
2d75916664
@ -23,6 +23,8 @@ import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.support.v4.content.AsyncTaskLoader;
|
||||
|
||||
import org.mozilla.gecko.GeckoApplication;
|
||||
|
||||
/**
|
||||
* A copy of the framework's {@link android.content.CursorLoader} that
|
||||
* instead allows the caller to load the Cursor themselves via the abstract
|
||||
@ -88,6 +90,10 @@ abstract class SimpleCursorLoader extends AsyncTaskLoader<Cursor> {
|
||||
|
||||
if (oldCursor != null && oldCursor != cursor && !oldCursor.isClosed()) {
|
||||
oldCursor.close();
|
||||
|
||||
// Trying to read from the closed cursor will cause crashes, hence we should make
|
||||
// sure that no adapters/LoaderCallbacks are holding onto this cursor.
|
||||
GeckoApplication.getRefWatcher(getContext()).watch(oldCursor);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user