mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Create custom column dialog: Fix exception if the library has no custom columns
This commit is contained in:
parent
cc96900aee
commit
c44af8e71a
@ -28,7 +28,9 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
self.custcols = copy.deepcopy(db.field_metadata.custom_field_metadata())
|
||||
for k, cc in self.custcols.items():
|
||||
cc['original_key'] = k
|
||||
self.initial_created_count = max(x['colnum'] for x in self.custcols.values()) + 1
|
||||
# Using max() in this way requires python 3.4+
|
||||
self.initial_created_count = max((x['colnum'] for x in self.custcols.values()),
|
||||
default=0) + 1
|
||||
self.created_count = self.initial_created_count
|
||||
|
||||
self.column_up.clicked.connect(self.up_column)
|
||||
|
@ -787,7 +787,8 @@ class CreateNewCustomColumn(object):
|
||||
self.custcols = copy.deepcopy(db.field_metadata.custom_field_metadata())
|
||||
# Get the largest internal column number so we can be sure that we can
|
||||
# detect duplicates.
|
||||
self.created_count = max(x['colnum'] for x in self.custcols.values()) + 1
|
||||
self.created_count = max((x['colnum'] for x in self.custcols.values()),
|
||||
default=0) + 1
|
||||
|
||||
def create_column(self, lookup_name, column_heading, datatype, is_multiple,
|
||||
display={}, generate_unused_lookup_name=False, freeze_lookup_name=True):
|
||||
|
Loading…
x
Reference in New Issue
Block a user