diff --git a/worldwind/src/androidMain/kotlin/earth/worldwind/util/ormlite/ConnectionSource.kt b/worldwind/src/androidMain/kotlin/earth/worldwind/util/ormlite/ConnectionSource.kt index 21420c023..a5009a6f6 100644 --- a/worldwind/src/androidMain/kotlin/earth/worldwind/util/ormlite/ConnectionSource.kt +++ b/worldwind/src/androidMain/kotlin/earth/worldwind/util/ormlite/ConnectionSource.kt @@ -1,9 +1,12 @@ package earth.worldwind.util.ormlite -import android.database.sqlite.SQLiteDatabase +import android.database.sqlite.SQLiteDatabase.* import com.j256.ormlite.android.AndroidConnectionSource import com.j256.ormlite.support.ConnectionSource actual fun initConnection(pathName: String, readOnly: Boolean): ConnectionSource = AndroidConnectionSource( - SQLiteDatabase.openDatabase(pathName, null, if (readOnly) SQLiteDatabase.OPEN_READONLY else SQLiteDatabase.OPEN_READWRITE or SQLiteDatabase.CREATE_IF_NECESSARY) + openDatabase( + pathName, null, + if (readOnly) OPEN_READONLY else OPEN_READWRITE or CREATE_IF_NECESSARY or ENABLE_WRITE_AHEAD_LOGGING + ).also { it.execSQL("PRAGMA synchronous = NORMAL") } ) \ No newline at end of file diff --git a/worldwind/src/commonMain/kotlin/earth/worldwind/render/RenderContext.kt b/worldwind/src/commonMain/kotlin/earth/worldwind/render/RenderContext.kt index c66959d00..aaa0b8198 100644 --- a/worldwind/src/commonMain/kotlin/earth/worldwind/render/RenderContext.kt +++ b/worldwind/src/commonMain/kotlin/earth/worldwind/render/RenderContext.kt @@ -360,7 +360,7 @@ open class RenderContext { inline fun getDrawablePool(): Pool { val key = T::class // use SynchronizedPool; acquire and are release may be called in separate threads - return drawablePools[key] as Pool? ?: SynchronizedPool().also { drawablePools[key] = it } + return drawablePools[key] as? Pool ?: SynchronizedPool().also { drawablePools[key] = it } } fun offerPickedObject(pickedObject: PickedObject) { pickedObjects?.offerPickedObject(pickedObject) } diff --git a/worldwind/src/jvmCommonMain/kotlin/earth/worldwind/ogc/gpkg/GeoPackage.kt b/worldwind/src/jvmCommonMain/kotlin/earth/worldwind/ogc/gpkg/GeoPackage.kt index 42c1be4f3..6b3c32d4e 100644 --- a/worldwind/src/jvmCommonMain/kotlin/earth/worldwind/ogc/gpkg/GeoPackage.kt +++ b/worldwind/src/jvmCommonMain/kotlin/earth/worldwind/ogc/gpkg/GeoPackage.kt @@ -86,16 +86,7 @@ open class GeoPackage(val pathName: String, val isReadOnly: Boolean = true) { } suspend fun readTilesDataSize(tableName: String) = withContext(Dispatchers.IO) { - val connection = connectionSource.getReadOnlyConnection(tableName) - - try { - connection.queryForLong("SELECT SUM(LENGTH(tile_data)) FROM '$tableName'") - } catch (e: SQLException) { - Logger.logMessage(Logger.WARN, "GeoPackage", "readTilesDataSize", "Could not read tiles data size", e) - 0L // Return zero if table does not exist - } finally { - connectionSource.releaseConnection(connection) - } + getTileUserDataDao(tableName).queryRawValue("SELECT SUM(LENGTH(tile_data)) FROM '$tableName'") } suspend fun readTileUserData(