Fix #1555871 [Manage user categories causes loss of sorting](https://bugs.launchpad.net/calibre/+bug/1555871)

Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
Kovid Goyal 2016-03-11 18:21:33 +05:30
commit 2f7857479d

View File

@ -111,10 +111,10 @@ class TagBrowserMixin(object): # {{{
d = TagCategories(self, db, on_category,
book_ids=self.tags_view.model().get_book_ids_to_use())
if d.exec_() == d.Accepted:
db.new_api.set_pref('user_categories', d.categories)
# Order is important. The categories must be removed before setting
# the preference because setting the pref recomputes the dynamic categories
db.field_metadata.remove_user_categories()
for k in d.categories:
db.field_metadata.add_user_category('@' + k, k)
db.new_api.set_pref('user_categories', d.categories)
db.new_api.refresh_search_locations()
self.tags_view.recount()