branch: elpa/emacsql
commit e1908de2cf2c7b77798ef6645d514dded1d7f8a4
Author: Martin Edström <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
emacsql-close: Only close if still open
Fix intermittent "wrong type argument: sqlitep nil".
Closes #132.
---
emacsql-sqlite-builtin.el | 5 +++--
emacsql-sqlite-module.el | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/emacsql-sqlite-builtin.el b/emacsql-sqlite-builtin.el
index 94edd26cbe5..2a7bf7f1e3a 100644
--- a/emacsql-sqlite-builtin.el
+++ b/emacsql-sqlite-builtin.el
@@ -49,8 +49,9 @@ buffer. This is for debugging purposes."
(and (oref connection handle) t))
(cl-defmethod emacsql-close ((connection emacsql-sqlite-builtin-connection))
- (sqlite-close (oref connection handle))
- (oset connection handle nil))
+ (when (oref connection handle)
+ (sqlite-close (oref connection handle))
+ (oset connection handle nil)))
(cl-defmethod emacsql-send-message
((connection emacsql-sqlite-builtin-connection) message)
diff --git a/emacsql-sqlite-module.el b/emacsql-sqlite-module.el
index 8dd1986e3d8..413a62605bd 100644
--- a/emacsql-sqlite-module.el
+++ b/emacsql-sqlite-module.el
@@ -55,8 +55,9 @@ buffer. This is for debugging purposes."
(and (oref connection handle) t))
(cl-defmethod emacsql-close ((connection emacsql-sqlite-module-connection))
- (sqlite3-close (oref connection handle))
- (oset connection handle nil))
+ (when (oref connection handle)
+ (sqlite3-close (oref connection handle))
+ (oset connection handle nil)))
(cl-defmethod emacsql-send-message
((connection emacsql-sqlite-module-connection) message)