mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Replace thread unsafe use of old db.prefs.set API
This commit is contained in:
parent
51b21ebe15
commit
49c412b023
@ -1360,7 +1360,7 @@ class DeviceMixin(object): # {{{
|
|||||||
|
|
||||||
def fset(self, ids):
|
def fset(self, ids):
|
||||||
try:
|
try:
|
||||||
self.library_view.model().db.prefs.set('news_to_be_synced',
|
self.library_view.model().db.new_api.set_pref('news_to_be_synced',
|
||||||
list(ids))
|
list(ids))
|
||||||
except:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -489,7 +489,7 @@ class BooksView(QTableView): # {{{
|
|||||||
db = getattr(self.model(), 'db', None)
|
db = getattr(self.model(), 'db', None)
|
||||||
name = unicode(self.objectName())
|
name = unicode(self.objectName())
|
||||||
if name and db is not None:
|
if name and db is not None:
|
||||||
db.prefs.set(name + ' books view state', state)
|
db.new_api.set_pref(name + ' books view state', state)
|
||||||
|
|
||||||
def save_state(self):
|
def save_state(self):
|
||||||
# Only save if we have been initialized (set_database called)
|
# Only save if we have been initialized (set_database called)
|
||||||
|
@ -392,7 +392,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
self.changed_signal.emit()
|
self.changed_signal.emit()
|
||||||
|
|
||||||
def commit(self):
|
def commit(self):
|
||||||
self.db.prefs.set('plugboards', self.current_plugboards)
|
self.db.new_api.set_pref('plugboards', self.current_plugboards)
|
||||||
return ConfigWidgetBase.commit(self)
|
return ConfigWidgetBase.commit(self)
|
||||||
|
|
||||||
def refresh_gui(self, gui):
|
def refresh_gui(self, gui):
|
||||||
|
@ -96,7 +96,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
self.gst_changed = False
|
self.gst_changed = False
|
||||||
|
|
||||||
if db.prefs.get('grouped_search_make_user_categories', None) is None:
|
if db.prefs.get('grouped_search_make_user_categories', None) is None:
|
||||||
db.prefs.set('grouped_search_make_user_categories', [])
|
db.new_api.set_pref('grouped_search_make_user_categories', [])
|
||||||
r('grouped_search_make_user_categories', db.prefs, setting=CommaSeparatedList)
|
r('grouped_search_make_user_categories', db.prefs, setting=CommaSeparatedList)
|
||||||
self.muc_changed = False
|
self.muc_changed = False
|
||||||
self.opt_grouped_search_make_user_categories.lineEdit().editingFinished.connect(
|
self.opt_grouped_search_make_user_categories.lineEdit().editingFinished.connect(
|
||||||
@ -212,15 +212,15 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
|
|
||||||
def commit(self):
|
def commit(self):
|
||||||
if self.gst_changed:
|
if self.gst_changed:
|
||||||
self.db.prefs.set('grouped_search_terms', self.gst)
|
self.db.new_api.set_pref('grouped_search_terms', self.gst)
|
||||||
self.db.field_metadata.add_grouped_search_terms(self.gst)
|
self.db.field_metadata.add_grouped_search_terms(self.gst)
|
||||||
self.db.prefs.set('similar_authors_search_key',
|
self.db.new_api.set_pref('similar_authors_search_key',
|
||||||
unicode(self.similar_authors_search_key.currentText()))
|
unicode(self.similar_authors_search_key.currentText()))
|
||||||
self.db.prefs.set('similar_tags_search_key',
|
self.db.new_api.set_pref('similar_tags_search_key',
|
||||||
unicode(self.similar_tags_search_key.currentText()))
|
unicode(self.similar_tags_search_key.currentText()))
|
||||||
self.db.prefs.set('similar_series_search_key',
|
self.db.new_api.set_pref('similar_series_search_key',
|
||||||
unicode(self.similar_series_search_key.currentText()))
|
unicode(self.similar_series_search_key.currentText()))
|
||||||
self.db.prefs.set('similar_publisher_search_key',
|
self.db.new_api.set_pref('similar_publisher_search_key',
|
||||||
unicode(self.similar_publisher_search_key.currentText()))
|
unicode(self.similar_publisher_search_key.currentText()))
|
||||||
return ConfigWidgetBase.commit(self)
|
return ConfigWidgetBase.commit(self)
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
for name, cls in self.funcs.iteritems():
|
for name, cls in self.funcs.iteritems():
|
||||||
if name not in self.builtins:
|
if name not in self.builtins:
|
||||||
pref_value.append((cls.name, cls.doc, cls.arg_count, cls.program_text))
|
pref_value.append((cls.name, cls.doc, cls.arg_count, cls.program_text))
|
||||||
self.db.prefs.set('user_template_functions', pref_value)
|
self.db.new_api.set_pref('user_template_functions', pref_value)
|
||||||
load_user_template_functions(self.db.library_id, pref_value)
|
load_user_template_functions(self.db.library_id, pref_value)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ class SearchRestrictionMixin(object):
|
|||||||
def add_virtual_library(self, db, name, search):
|
def add_virtual_library(self, db, name, search):
|
||||||
virt_libs = db.prefs.get('virtual_libraries', {})
|
virt_libs = db.prefs.get('virtual_libraries', {})
|
||||||
virt_libs[name] = search
|
virt_libs[name] = search
|
||||||
db.prefs.set('virtual_libraries', virt_libs)
|
db.new_api.set_pref('virtual_libraries', virt_libs)
|
||||||
|
|
||||||
def do_create_edit(self, name=None):
|
def do_create_edit(self, name=None):
|
||||||
db = self.library_view.model().db
|
db = self.library_view.model().db
|
||||||
@ -490,7 +490,7 @@ class SearchRestrictionMixin(object):
|
|||||||
db = self.library_view.model().db
|
db = self.library_view.model().db
|
||||||
virt_libs = db.prefs.get('virtual_libraries', {})
|
virt_libs = db.prefs.get('virtual_libraries', {})
|
||||||
virt_libs.pop(name, None)
|
virt_libs.pop(name, None)
|
||||||
db.prefs.set('virtual_libraries', virt_libs)
|
db.new_api.set_pref('virtual_libraries', virt_libs)
|
||||||
if reapply and db.data.get_base_restriction_name() == name:
|
if reapply and db.data.get_base_restriction_name() == name:
|
||||||
self.apply_virtual_library('')
|
self.apply_virtual_library('')
|
||||||
self.rebuild_vl_tabs()
|
self.rebuild_vl_tabs()
|
||||||
|
@ -732,7 +732,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
is_uc, dest_key,
|
is_uc, dest_key,
|
||||||
self.get_node(idx))
|
self.get_node(idx))
|
||||||
|
|
||||||
self.db.prefs.set('user_categories', user_cats)
|
self.db.new_api.set_pref('user_categories', user_cats)
|
||||||
self.refresh_required.emit()
|
self.refresh_required.emit()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@ -801,7 +801,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
cat_contents |= set([(v, column) for v in value])
|
cat_contents |= set([(v, column) for v in value])
|
||||||
|
|
||||||
categories[on_node.category_key[1:]] = [[v, c, 0] for v,c in cat_contents]
|
categories[on_node.category_key[1:]] = [[v, c, 0] for v,c in cat_contents]
|
||||||
self.db.prefs.set('user_categories', categories)
|
self.db.new_api.set_pref('user_categories', categories)
|
||||||
self.refresh_required.emit()
|
self.refresh_required.emit()
|
||||||
|
|
||||||
def handle_drop(self, on_node, ids):
|
def handle_drop(self, on_node, ids):
|
||||||
@ -1072,7 +1072,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
else:
|
else:
|
||||||
new_contents.append(tup)
|
new_contents.append(tup)
|
||||||
user_cats[k] = new_contents
|
user_cats[k] = new_contents
|
||||||
self.db.prefs.set('user_categories', user_cats)
|
self.db.new_api.set_pref('user_categories', user_cats)
|
||||||
|
|
||||||
def delete_item_from_all_user_categories(self, item_name, item_category):
|
def delete_item_from_all_user_categories(self, item_name, item_category):
|
||||||
'''
|
'''
|
||||||
@ -1084,7 +1084,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
for cat in user_cats.keys():
|
for cat in user_cats.keys():
|
||||||
self.delete_item_from_user_category(cat, item_name, item_category,
|
self.delete_item_from_user_category(cat, item_name, item_category,
|
||||||
user_categories=user_cats)
|
user_categories=user_cats)
|
||||||
self.db.prefs.set('user_categories', user_cats)
|
self.db.new_api.set_pref('user_categories', user_cats)
|
||||||
|
|
||||||
def delete_item_from_user_category(self, category, item_name, item_category,
|
def delete_item_from_user_category(self, category, item_name, item_category,
|
||||||
user_categories=None):
|
user_categories=None):
|
||||||
@ -1098,7 +1098,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
new_contents.append(tup)
|
new_contents.append(tup)
|
||||||
user_cats[category] = new_contents
|
user_cats[category] = new_contents
|
||||||
if user_categories is None:
|
if user_categories is None:
|
||||||
self.db.prefs.set('user_categories', user_cats)
|
self.db.new_api.set_pref('user_categories', user_cats)
|
||||||
|
|
||||||
def headerData(self, *args):
|
def headerData(self, *args):
|
||||||
return None
|
return None
|
||||||
|
@ -94,7 +94,7 @@ class TagBrowserMixin(object): # {{{
|
|||||||
n = new_name + unicode(i)
|
n = new_name + unicode(i)
|
||||||
# Add the new category
|
# Add the new category
|
||||||
user_cats[new_cat] = []
|
user_cats[new_cat] = []
|
||||||
db.prefs.set('user_categories', user_cats)
|
db.new_api.set_pref('user_categories', user_cats)
|
||||||
self.tags_view.recount()
|
self.tags_view.recount()
|
||||||
m = self.tags_view.model()
|
m = self.tags_view.model()
|
||||||
idx = m.index_for_path(m.find_category_node('@' + new_cat))
|
idx = m.index_for_path(m.find_category_node('@' + new_cat))
|
||||||
@ -110,7 +110,7 @@ class TagBrowserMixin(object): # {{{
|
|||||||
db = self.library_view.model().db
|
db = self.library_view.model().db
|
||||||
d = TagCategories(self, db, on_category)
|
d = TagCategories(self, db, on_category)
|
||||||
if d.exec_() == d.Accepted:
|
if d.exec_() == d.Accepted:
|
||||||
db.prefs.set('user_categories', d.categories)
|
db.new_api.set_pref('user_categories', d.categories)
|
||||||
db.field_metadata.remove_user_categories()
|
db.field_metadata.remove_user_categories()
|
||||||
for k in d.categories:
|
for k in d.categories:
|
||||||
db.field_metadata.add_user_category('@' + k, k)
|
db.field_metadata.add_user_category('@' + k, k)
|
||||||
@ -147,7 +147,7 @@ class TagBrowserMixin(object): # {{{
|
|||||||
del user_cats[k]
|
del user_cats[k]
|
||||||
elif k.startswith(category_name + '.'):
|
elif k.startswith(category_name + '.'):
|
||||||
del user_cats[k]
|
del user_cats[k]
|
||||||
db.prefs.set('user_categories', user_cats)
|
db.new_api.set_pref('user_categories', user_cats)
|
||||||
self.tags_view.recount()
|
self.tags_view.recount()
|
||||||
|
|
||||||
def do_del_item_from_user_cat(self, user_cat, item_name, item_category):
|
def do_del_item_from_user_cat(self, user_cat, item_name, item_category):
|
||||||
@ -192,7 +192,7 @@ class TagBrowserMixin(object): # {{{
|
|||||||
add_it = False
|
add_it = False
|
||||||
if add_it:
|
if add_it:
|
||||||
user_cats[dest_category].append([src_name, src_category, 0])
|
user_cats[dest_category].append([src_name, src_category, 0])
|
||||||
db.prefs.set('user_categories', user_cats)
|
db.new_api.set_pref('user_categories', user_cats)
|
||||||
self.tags_view.recount()
|
self.tags_view.recount()
|
||||||
|
|
||||||
def do_tags_list_edit(self, tag, category):
|
def do_tags_list_edit(self, tag, category):
|
||||||
|
@ -208,7 +208,7 @@ class TagsView(QTreeView): # {{{
|
|||||||
|
|
||||||
def user_categories_edited(self, user_cats, nkey):
|
def user_categories_edited(self, user_cats, nkey):
|
||||||
state_map = self.get_state()[1]
|
state_map = self.get_state()[1]
|
||||||
self.db.prefs.set('user_categories', user_cats)
|
self.db.new_api.set_pref('user_categories', user_cats)
|
||||||
self._model.rebuild_node_tree(state_map=state_map)
|
self._model.rebuild_node_tree(state_map=state_map)
|
||||||
p = self._model.find_category_node('@'+nkey)
|
p = self._model.find_category_node('@'+nkey)
|
||||||
self.show_item_at_path(p)
|
self.show_item_at_path(p)
|
||||||
@ -408,7 +408,7 @@ class TagsView(QTreeView): # {{{
|
|||||||
gprefs['tags_browser_partition_method'] = category
|
gprefs['tags_browser_partition_method'] = category
|
||||||
elif action == 'defaults':
|
elif action == 'defaults':
|
||||||
self.hidden_categories.clear()
|
self.hidden_categories.clear()
|
||||||
self.db.prefs.set('tag_browser_hidden_categories', list(self.hidden_categories))
|
self.db.new_api.set_pref('tag_browser_hidden_categories', list(self.hidden_categories))
|
||||||
if reset_filter_categories:
|
if reset_filter_categories:
|
||||||
self._model.set_categories_filter(None)
|
self._model.set_categories_filter(None)
|
||||||
self._model.rebuild_node_tree()
|
self._model.rebuild_node_tree()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user