am 98d88588: am ba223760: Close suggestion cursors that arrive after adapter is closed

Merge commit '98d8858890227861c5dc28bc7acee9b1adedda45' into eclair-plus-aosp

* commit '98d8858890227861c5dc28bc7acee9b1adedda45':
  Close suggestion cursors that arrive after adapter is closed
This commit is contained in:
Bjorn Bringert
2009-08-26 11:44:09 -07:00
committed by Android Git Automerger
2 changed files with 14 additions and 1 deletions

View File

@@ -428,7 +428,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
mSearchAutoComplete.setAdapter((SuggestionsAdapter)null); mSearchAutoComplete.setAdapter((SuggestionsAdapter)null);
// close any leftover cursor // close any leftover cursor
if (mSuggestionsAdapter != null) { if (mSuggestionsAdapter != null) {
mSuggestionsAdapter.changeCursor(null); mSuggestionsAdapter.close();
} }
mSuggestionsAdapter = null; mSuggestionsAdapter = null;
} }

View File

@@ -65,6 +65,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
private WeakHashMap<String, Drawable.ConstantState> mOutsideDrawablesCache; private WeakHashMap<String, Drawable.ConstantState> mOutsideDrawablesCache;
private SparseArray<Drawable.ConstantState> mBackgroundsCache; private SparseArray<Drawable.ConstantState> mBackgroundsCache;
private boolean mGlobalSearchMode; private boolean mGlobalSearchMode;
private boolean mClosed = false;
// Cached column indexes, updated when the cursor changes. // Cached column indexes, updated when the cursor changes.
private int mFormatCol; private int mFormatCol;
@@ -199,6 +200,12 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
} }
} }
public void close() {
if (DBG) Log.d(LOG_TAG, "close()");
changeCursor(null);
mClosed = true;
}
/** /**
* Cache columns. * Cache columns.
*/ */
@@ -206,6 +213,12 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
public void changeCursor(Cursor c) { public void changeCursor(Cursor c) {
if (DBG) Log.d(LOG_TAG, "changeCursor(" + c + ")"); if (DBG) Log.d(LOG_TAG, "changeCursor(" + c + ")");
if (mClosed) {
Log.w(LOG_TAG, "Tried to change cursor after adapter was closed.");
if (c != null) c.close();
return;
}
try { try {
Cursor oldCursor = getCursor(); Cursor oldCursor = getCursor();
super.changeCursor(c); super.changeCursor(c);