зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1257667 - Try to catch stale cursor usage using LeakCanary r=sebastian
MozReview-Commit-ID: Ga5lPgwpIxp
This commit is contained in:
Родитель
1df58c3516
Коммит
4ca8060282
|
@ -23,6 +23,8 @@ import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.support.v4.content.AsyncTaskLoader;
|
import android.support.v4.content.AsyncTaskLoader;
|
||||||
|
|
||||||
|
import org.mozilla.gecko.GeckoApplication;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A copy of the framework's {@link android.content.CursorLoader} that
|
* A copy of the framework's {@link android.content.CursorLoader} that
|
||||||
* instead allows the caller to load the Cursor themselves via the abstract
|
* instead allows the caller to load the Cursor themselves via the abstract
|
||||||
|
@ -87,6 +89,10 @@ abstract class SimpleCursorLoader extends AsyncTaskLoader<Cursor> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldCursor != null && oldCursor != cursor && !oldCursor.isClosed()) {
|
if (oldCursor != null && oldCursor != cursor && !oldCursor.isClosed()) {
|
||||||
|
// 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);
|
||||||
|
|
||||||
oldCursor.close();
|
oldCursor.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче