]> git.notmuchmail.org Git - notmuch/blobdiff - lib/database.cc
Actually close the xapian database in notmuch_database_close
[notmuch] / lib / database.cc
index 5efa85eb162ab47085f4105ebd5b0a0a86f84ddd..8f8df1a1434ed604ca2fe1a7bdf5f87b7084a28d 100644 (file)
@@ -726,6 +726,17 @@ notmuch_database_close (notmuch_database_t *notmuch)
        }
     }
 
+    /* Many Xapian objects (and thus notmuch objects) hold references to
+     * the database, so merely deleting the database may not suffice to
+     * close it.  Thus, we explicitly close it here. */
+    if (notmuch->xapian_db != NULL) {
+       try {
+           notmuch->xapian_db->close();
+       } catch (const Xapian::Error &error) {
+           /* do nothing */
+       }
+    }
+
     delete notmuch->term_gen;
     delete notmuch->query_parser;
     delete notmuch->xapian_db;