From dc72fc0de7c2b07768a003f7f5b445d936343e58 Mon Sep 17 00:00:00 2001 From: DaPa Date: Thu, 17 Jun 2021 22:18:55 +0300 Subject: [PATCH 1/2] Avoid SQLite connection object leaking - W/SQLiteConnectionPool: A SQLiteConnection object for database '/data/user/0/com.simplemobiletools.gallery.pro/databases/gallery.db' was leaked! Please fix your application to end transactions in progress properly and to close the database when it is no longer needed. Happens to me on Android 11 (Moto g 5G plus, with Google Photos disabled): - open Camera, then click on the small picture thumbnail from bottom-right corner which should open the Gallery app - in this scenario sometimes, the Simple Gallery was crashing and the above warning was seen in the logs... - no more crash after this patch: please review/test properly before incorporating! --- .../gallery/pro/databases/GalleryDatabase.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/databases/GalleryDatabase.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/databases/GalleryDatabase.kt index 0b41a17d6..b29066036 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/databases/GalleryDatabase.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/databases/GalleryDatabase.kt @@ -44,6 +44,11 @@ abstract class GalleryDatabase : RoomDatabase() { } fun destroyInstance() { + if (db != null) { + if(db!!.isOpen) { + db?.close(); + } + } db = null } From e603663f0bd058cff981be2e784d757e1548fc76 Mon Sep 17 00:00:00 2001 From: Tibor Kaputa Date: Fri, 18 Jun 2021 10:00:46 +0200 Subject: [PATCH 2/2] Update GalleryDatabase.kt --- .../gallery/pro/databases/GalleryDatabase.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/databases/GalleryDatabase.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/databases/GalleryDatabase.kt index b29066036..2436e87bd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/databases/GalleryDatabase.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/databases/GalleryDatabase.kt @@ -44,10 +44,8 @@ abstract class GalleryDatabase : RoomDatabase() { } fun destroyInstance() { - if (db != null) { - if(db!!.isOpen) { - db?.close(); - } + if (db?.isOpen == true) { + db?.close() } db = null }