diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2010-06-04 12:58:09 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-06-04 12:58:09 -0700 |
commit | 7c035d8a65626b8fed6e7da46477137ab9d5573e (patch) | |
tree | 01777eb0d50d2324e7a7e69a348b56f2c6649d6f /core/java | |
parent | f8acea6ccbdd7e7283b1dc439f49c72a937f746d (diff) | |
parent | 2d743fe2f39397d41334001d897eb78da56e94ef (diff) | |
download | frameworks_base-7c035d8a65626b8fed6e7da46477137ab9d5573e.zip frameworks_base-7c035d8a65626b8fed6e7da46477137ab9d5573e.tar.gz frameworks_base-7c035d8a65626b8fed6e7da46477137ab9d5573e.tar.bz2 |
am 2d743fe2: merge from open-source master
Merge commit '2d743fe2f39397d41334001d897eb78da56e94ef' into kraken
* commit '2d743fe2f39397d41334001d897eb78da56e94ef':
Add better error handling for savePicture and restorePicture
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/webkit/WebView.java | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 921d0f5..ac23832 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -1380,16 +1380,23 @@ public class WebView extends AbsoluteLayout final File temp = new File(dest.getPath() + ".writing"); new Thread(new Runnable() { public void run() { + FileOutputStream out = null; try { - FileOutputStream out = new FileOutputStream(temp); + out = new FileOutputStream(temp); p.writeToStream(out); - out.close(); // Writing the picture succeeded, rename the temporary file // to the destination. temp.renameTo(dest); } catch (Exception e) { // too late to do anything about it. } finally { + if (out != null) { + try { + out.close(); + } catch (Exception e) { + // Can't do anything about that + } + } temp.delete(); } } @@ -1442,20 +1449,23 @@ public class WebView extends AbsoluteLayout final Bundle copy = new Bundle(b); new Thread(new Runnable() { public void run() { - final Picture p = Picture.createFromStream(in); - if (p != null) { - // Post a runnable on the main thread to update the - // history picture fields. - mPrivateHandler.post(new Runnable() { - public void run() { - restoreHistoryPictureFields(p, copy); - } - }); - } try { - in.close(); - } catch (Exception e) { - // Nothing we can do now. + final Picture p = Picture.createFromStream(in); + if (p != null) { + // Post a runnable on the main thread to update the + // history picture fields. + mPrivateHandler.post(new Runnable() { + public void run() { + restoreHistoryPictureFields(p, copy); + } + }); + } + } finally { + try { + in.close(); + } catch (Exception e) { + // Nothing we can do now. + } } } }).start(); |