From e040aa388b9ce5bf18003e56fb9a38e08ae20fe4 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 12 Nov 2013 08:08:30 -0800 Subject: [PATCH] don't try to save to read-only lock; check for non-existant games when summarizing: together these fix crash when deleting after opening game whose remote partner has been deleted. --- .../XWords4/src/org/eehouse/android/xw4/DBUtils.java | 2 +- .../XWords4/src/org/eehouse/android/xw4/GameUtils.java | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java index 4a4b32ca7..e77420fae 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java @@ -256,7 +256,7 @@ public class DBUtils { db.close(); } - if ( null == summary ) { + if ( null == summary && lock.canWrite() ) { summary = GameUtils.summarize( context, lock ); saveSummary( context, lock, summary ); } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java index b8b32be5d..0eb7f6eb1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java @@ -187,10 +187,13 @@ public class GameUtils { public static GameSummary summarize( Context context, GameLock lock ) { + GameSummary result = null; CurGameInfo gi = new CurGameInfo( context ); int gamePtr = loadMakeGame( context, gi, lock ); - - return summarizeAndClose( context, lock, gamePtr, gi ); + if ( 0 < gamePtr ) { + result = summarizeAndClose( context, lock, gamePtr, gi ); + } + return result; } public static long dupeGame( Context context, long rowidIn )