зеркало из https://github.com/mozilla/gecko-dev.git
Bug 856739 - AwesomeBar.onDestroy does DB access on the main thread r=lucasr
This commit is contained in:
Родитель
6aab04ff84
Коммит
b59e551f4a
|
@ -147,19 +147,26 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
|
|||
|
||||
@Override
|
||||
public void destroy() {
|
||||
AwesomeBarCursorAdapter adapter = getCursorAdapter();
|
||||
unregisterEventListener("SearchEngines:Data");
|
||||
if (adapter == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Cursor cursor = adapter.getCursor();
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
|
||||
mHandler.removeMessages(MESSAGE_UPDATE_FAVICONS);
|
||||
mHandler.removeMessages(MESSAGE_LOAD_FAVICONS);
|
||||
mHandler = null;
|
||||
|
||||
// Can't use getters for adapter or listview. They will create them if null.
|
||||
if (mCursorAdapter != null && mListView != null) {
|
||||
mListView.setAdapter(null);
|
||||
final Cursor cursor = mCursorAdapter.getCursor();
|
||||
// Gingerbread locks the DB when closing a cursor, so do it in the
|
||||
// background.
|
||||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (cursor != null && !cursor.isClosed())
|
||||
cursor.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void filter(String searchTerm) {
|
||||
|
|
|
@ -93,14 +93,21 @@ public class BookmarksTab extends AwesomeBarTab {
|
|||
|
||||
@Override
|
||||
public void destroy() {
|
||||
BookmarksListAdapter adapter = getCursorAdapter();
|
||||
if (adapter == null) {
|
||||
return;
|
||||
// Can't use getters for adapter. It will create one if null.
|
||||
if (mCursorAdapter != null && mView != null) {
|
||||
ListView list = (ListView)mView;
|
||||
list.setAdapter(null);
|
||||
final Cursor cursor = mCursorAdapter.getCursor();
|
||||
// Gingerbread locks the DB when closing a cursor, so do it in the
|
||||
// background.
|
||||
ThreadUtils.postToBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (cursor != null && !cursor.isClosed())
|
||||
cursor.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Cursor cursor = adapter.getCursor();
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Загрузка…
Ссылка в новой задаче