This commit is contained in:
Kovid Goyal 2016-09-13 15:42:24 +05:30
commit 5c366c0201
2 changed files with 5 additions and 4 deletions

View File

@ -31,7 +31,7 @@ from calibre.utils.filenames import (
WindowsAtomicFolderMove, atomic_rename, remove_dir_if_empty,
copytree_using_links, copyfile_using_links)
from calibre.utils.img import save_cover_data_to
from calibre.utils.formatter_functions import load_user_template_functions
from calibre.utils.formatter_functions import load_user_template_functions, unload_user_template_functions
from calibre.db.tables import (OneToOneTable, ManyToOneTable, ManyToManyTable,
SizeTable, FormatsTable, AuthorsTable, IdentifiersTable, PathTable,
CompositeTable, UUIDTable, RatingTable)
@ -1033,6 +1033,10 @@ class DB(object):
def close(self, force=False):
if getattr(self, '_conn', None) is not None:
try:
unload_user_template_functions(self.library_id)
except Exception:
pass
self._conn.close(force)
del self._conn

View File

@ -634,9 +634,6 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
olddb = self.library_view.model().db
if copy_structure:
default_prefs = olddb.prefs
from calibre.utils.formatter_functions import unload_user_template_functions
unload_user_template_functions(olddb.library_id)
except:
olddb = None
try: