diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2015-01-04 09:27:52 +0100 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2015-01-04 09:27:52 +0100 |
| commit | b26c135e3a401815924f628d40b94f4b6fcd55ec (patch) | |
| tree | 1d03dfb0934c2bb917e1177f8a384280e0af52ee | |
| parent | ecdaa6fb9e980b5b402e2a20c2950f8005833ff3 (diff) | |
| download | cgeo-b26c135e3a401815924f628d40b94f4b6fcd55ec.zip cgeo-b26c135e3a401815924f628d40b94f4b6fcd55ec.tar.gz cgeo-b26c135e3a401815924f628d40b94f4b6fcd55ec.tar.bz2 | |
fix #4557: NPE when performing backup
| -rw-r--r-- | main/src/cgeo/geocaching/DataStore.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/main/src/cgeo/geocaching/DataStore.java b/main/src/cgeo/geocaching/DataStore.java index b5a4a7a..2b51db9 100644 --- a/main/src/cgeo/geocaching/DataStore.java +++ b/main/src/cgeo/geocaching/DataStore.java @@ -1945,7 +1945,7 @@ public class DataStore { init(); final Cursor cursor = database.rawQuery( - /* 0 1 2 3 4 5 6 7 8 9 10 */ + // 0 1 2 3 4 5 6 7 8 9 10 "SELECT cg_logs._id as cg_logs_id, type, author, log, date, found, friend, " + dbTableLogImages + "._id as cg_logImages_id, log_id, title, url" + " FROM " + dbTableLogs + " LEFT OUTER JOIN " + dbTableLogImages + " ON ( cg_logs._id = log_id ) WHERE geocode = ? ORDER BY date desc, cg_logs._id asc", new String[]{geocode}); @@ -2978,18 +2978,19 @@ public class DataStore { } private SQLiteStatement getStatement() { - if (statement == null) { - init(); - statement = database.compileStatement(query); - statements.add(this); + synchronized (statements) { + if (statement == null) { + init(); + statement = database.compileStatement(query); + statements.add(this); + } + return statement; } - return statement; } private static void clearPreparedStatements() { for (final PreparedStatement preparedStatement : statements) { preparedStatement.statement.close(); - preparedStatement.statement = null; } statements.clear(); } |
