diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2010-11-01 12:55:18 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-11-01 12:55:18 -0700 |
commit | 64c3e551ae13c9c4fa2b42e47c123620ddaef581 (patch) | |
tree | d48d2b1d8376cff3ce172b81bee0ba9a20fdd1b2 /src | |
parent | 8adc828f4df3f3856f42750ccf2892ba27c93d86 (diff) | |
parent | 8187c15d1c7f714c30573b9480ffb4bee18b96d7 (diff) | |
download | packages_apps_Browser-64c3e551ae13c9c4fa2b42e47c123620ddaef581.zip packages_apps_Browser-64c3e551ae13c9c4fa2b42e47c123620ddaef581.tar.gz packages_apps_Browser-64c3e551ae13c9c4fa2b42e47c123620ddaef581.tar.bz2 |
am 8187c15d: Merge "Cursor leak in share_link_context_menu."
* commit '8187c15d1c7f714c30573b9480ffb4bee18b96d7':
Cursor leak in share_link_context_menu.
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/browser/BrowserActivity.java | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java index 6271e24..0a3fec9 100644 --- a/src/com/android/browser/BrowserActivity.java +++ b/src/com/android/browser/BrowserActivity.java @@ -2273,36 +2273,41 @@ public class BrowserActivity extends Activity StringBuilder sb = new StringBuilder( Browser.BookmarkColumns.URL + " = "); DatabaseUtils.appendEscapedSQLString(sb, url); - Cursor c = mResolver.query(Browser.BOOKMARKS_URI, - Browser.HISTORY_PROJECTION, - sb.toString(), - null, - null); - if (c.moveToFirst()) { - // The site has been visited before, so grab the - // info from the database. - Bitmap favicon = null; - Bitmap thumbnail = null; - String linkTitle = c.getString(Browser. - HISTORY_PROJECTION_TITLE_INDEX); - byte[] data = c.getBlob(Browser. - HISTORY_PROJECTION_FAVICON_INDEX); - if (data != null) { - favicon = BitmapFactory.decodeByteArray( - data, 0, data.length); + Cursor c = null; + try { + c = mResolver.query(Browser.BOOKMARKS_URI, + Browser.HISTORY_PROJECTION, + sb.toString(), + null, + null); + if (c.moveToFirst()) { + // The site has been visited before, so grab the + // info from the database. + Bitmap favicon = null; + Bitmap thumbnail = null; + String linkTitle = c.getString(Browser. + HISTORY_PROJECTION_TITLE_INDEX); + byte[] data = c.getBlob(Browser. + HISTORY_PROJECTION_FAVICON_INDEX); + if (data != null) { + favicon = BitmapFactory.decodeByteArray( + data, 0, data.length); + } + data = c.getBlob(Browser. + HISTORY_PROJECTION_THUMBNAIL_INDEX); + if (data != null) { + thumbnail = BitmapFactory.decodeByteArray( + data, 0, data.length); + } + sharePage(BrowserActivity.this, + linkTitle, url, favicon, thumbnail); + } else { + Browser.sendString(BrowserActivity.this, url, + getString( + R.string.choosertitle_sharevia)); } - data = c.getBlob(Browser. - HISTORY_PROJECTION_THUMBNAIL_INDEX); - if (data != null) { - thumbnail = BitmapFactory.decodeByteArray( - data, 0, data.length); - } - sharePage(BrowserActivity.this, - linkTitle, url, favicon, thumbnail); - } else { - Browser.sendString(BrowserActivity.this, url, - getString( - R.string.choosertitle_sharevia)); + } finally { + if (c != null) c.close(); } // close the cursor after its used if (c != null) { |