summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorRomain Guy <romainguy@android.com>2010-06-03 14:26:21 -0700
committerAndroid Code Review <code-review@android.com>2010-06-03 14:26:21 -0700
commitfb59fbf14e3d8580ad8702343795f03b2f823295 (patch)
treeab8b8f3a9bc04aa4bbc5dae4787a2dd225ecb149 /core
parente99c012503bbd205cbaa9f16f9894ca5ffeaaf76 (diff)
parentdad86349bea3aec1d48793adc61b446f82311d15 (diff)
downloadframeworks_base-fb59fbf14e3d8580ad8702343795f03b2f823295.zip
frameworks_base-fb59fbf14e3d8580ad8702343795f03b2f823295.tar.gz
frameworks_base-fb59fbf14e3d8580ad8702343795f03b2f823295.tar.bz2
Merge "Add better error handling for savePicture and restorePicture"
Diffstat (limited to 'core')
-rw-r--r--core/java/android/webkit/WebView.java28
1 files changed, 23 insertions, 5 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index c5c14d3..de450fc 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -1182,18 +1182,29 @@ public class WebView extends AbsoluteLayout
return false;
}
final Picture p = capturePicture();
+
+ FileOutputStream out = null;
+ boolean success = false;
try {
- final FileOutputStream out = new FileOutputStream(dest);
+ out = new FileOutputStream(dest);
p.writeToStream(out);
- out.close();
+ success = true;
} catch (FileNotFoundException e){
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (RuntimeException e) {
e.printStackTrace();
+ } finally {
+ if (out != null) {
+ try {
+ out.close();
+ } catch (Throwable t) {
+ }
+ }
}
- if (dest.length() > 0) {
+
+ if (success && dest.length() > 0) {
b.putInt("scrollX", mScrollX);
b.putInt("scrollY", mScrollY);
b.putFloat("scale", mActualScale);
@@ -1217,16 +1228,23 @@ public class WebView extends AbsoluteLayout
}
if (src.exists()) {
Picture p = null;
+ FileInputStream in = null;
try {
- final FileInputStream in = new FileInputStream(src);
+ in = new FileInputStream(src);
p = Picture.createFromStream(in);
- in.close();
} catch (FileNotFoundException e){
e.printStackTrace();
} catch (RuntimeException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (Throwable t) {
+ }
+ }
}
if (p != null) {
int sx = b.getInt("scrollX", 0);