Fix #308
Add null check when loading community_rating Use iterators instead of while loops
This commit is contained in:
parent
4c9fa4f716
commit
62d927a104
@ -113,8 +113,7 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
|
||||
if not self.current_match_set:
|
||||
return
|
||||
|
||||
while self.twList.rowCount() > 0:
|
||||
self.twList.removeRow(0)
|
||||
self.twList.setRowCount(0)
|
||||
|
||||
self.twList.setSortingEnabled(False)
|
||||
|
||||
|
@ -233,12 +233,10 @@ class FileSelectionList(QtWidgets.QWidget):
|
||||
return self.get_current_list_row(path) >= 0
|
||||
|
||||
def get_current_list_row(self, path: str) -> int:
|
||||
r = 0
|
||||
while r < self.twList.rowCount():
|
||||
for r in range(self.twList.rowCount()):
|
||||
ca = cast(ComicArchive, self.get_archive_by_row(r))
|
||||
if ca.path == path:
|
||||
return r
|
||||
r = r + 1
|
||||
|
||||
return -1
|
||||
|
||||
|
@ -108,8 +108,7 @@ class IssueSelectionWindow(QtWidgets.QDialog):
|
||||
QtWidgets.QMessageBox.critical(self, "Network Issue", "Could not connect to Comic Vine to list issues!")
|
||||
return
|
||||
|
||||
while self.twList.rowCount() > 0:
|
||||
self.twList.removeRow(0)
|
||||
self.twList.setRowCount(0)
|
||||
|
||||
self.twList.setSortingEnabled(False)
|
||||
|
||||
|
@ -78,8 +78,7 @@ class MatchSelectionWindow(QtWidgets.QDialog):
|
||||
|
||||
def populate_table(self) -> None:
|
||||
|
||||
while self.twList.rowCount() > 0:
|
||||
self.twList.removeRow(0)
|
||||
self.twList.setRowCount(0)
|
||||
|
||||
self.twList.setSortingEnabled(False)
|
||||
|
||||
|
@ -75,8 +75,7 @@ class RenameWindow(QtWidgets.QDialog):
|
||||
self.renamer.set_smart_cleanup(self.settings.rename_use_smart_string_cleanup)
|
||||
|
||||
def do_preview(self) -> None:
|
||||
while self.twList.rowCount() > 0:
|
||||
self.twList.removeRow(0)
|
||||
self.twList.setRowCount(0)
|
||||
|
||||
self.twList.setSortingEnabled(False)
|
||||
|
||||
|
@ -744,8 +744,7 @@ Have fun!
|
||||
if isinstance(widget, QtWidgets.QCheckBox):
|
||||
widget.setChecked(False)
|
||||
if isinstance(widget, QtWidgets.QTableWidget):
|
||||
while widget.rowCount() > 0:
|
||||
widget.removeRow(0)
|
||||
widget.setRowCount(0)
|
||||
|
||||
# recursive call on children
|
||||
for child in widget.children():
|
||||
@ -787,7 +786,7 @@ Have fun!
|
||||
assign_text(self.teLocations, md.locations)
|
||||
|
||||
try:
|
||||
self.dsbCommunityRating.setValue(md.community_rating)
|
||||
self.dsbCommunityRating.setValue(md.community_rating or 0.0)
|
||||
except ValueError:
|
||||
self.dsbCommunityRating.setValue(0.0)
|
||||
|
||||
@ -832,8 +831,7 @@ Have fun!
|
||||
|
||||
self.teTags.setText(utils.list_to_string(md.tags))
|
||||
|
||||
while self.twCredits.rowCount() > 0:
|
||||
self.twCredits.removeRow(0)
|
||||
self.twCredits.setRowCount(0)
|
||||
|
||||
if md.credits is not None and len(md.credits) != 0:
|
||||
self.twCredits.setSortingEnabled(False)
|
||||
@ -874,11 +872,9 @@ Have fun!
|
||||
self.update_credit_primary_flag(row, primary_flag)
|
||||
|
||||
def is_dupe_credit(self, role: str, name: str) -> bool:
|
||||
r = 0
|
||||
while r < self.twCredits.rowCount():
|
||||
for r in range(self.twCredits.rowCount()):
|
||||
if self.twCredits.item(r, 1).text() == role and self.twCredits.item(r, 2).text() == name:
|
||||
return True
|
||||
r = r + 1
|
||||
|
||||
return False
|
||||
|
||||
@ -939,14 +935,12 @@ Have fun!
|
||||
|
||||
# get the credits from the table
|
||||
md.credits = []
|
||||
row = 0
|
||||
while row < self.twCredits.rowCount():
|
||||
for row in range(self.twCredits.rowCount()):
|
||||
role = self.twCredits.item(row, 1).text()
|
||||
name = self.twCredits.item(row, 2).text()
|
||||
primary_flag = self.twCredits.item(row, 0).text() != ""
|
||||
|
||||
md.add_credit(name, role, bool(primary_flag))
|
||||
row += 1
|
||||
|
||||
md.pages = self.page_list_editor.get_page_list()
|
||||
self.metadata = md
|
||||
@ -1138,22 +1132,20 @@ Have fun!
|
||||
if self.save_data_style == MetaDataStyle.CIX:
|
||||
# loop over credit table, mark selected rows
|
||||
r = 0
|
||||
while r < self.twCredits.rowCount():
|
||||
for r in range(self.twCredits.rowCount()):
|
||||
if str(self.twCredits.item(r, 1).text()).lower() not in cix_credits:
|
||||
self.twCredits.item(r, 1).setBackground(inactive_brush)
|
||||
else:
|
||||
self.twCredits.item(r, 1).setBackground(active_brush)
|
||||
# turn off entire primary column
|
||||
self.twCredits.item(r, 0).setBackground(inactive_brush)
|
||||
r = r + 1
|
||||
|
||||
if self.save_data_style == MetaDataStyle.CBI:
|
||||
# loop over credit table, make all active color
|
||||
r = 0
|
||||
while r < self.twCredits.rowCount():
|
||||
for r in range(self.twCredits.rowCount()):
|
||||
self.twCredits.item(r, 0).setBackground(active_brush)
|
||||
self.twCredits.item(r, 1).setBackground(active_brush)
|
||||
r = r + 1
|
||||
|
||||
def update_style_tweaks(self) -> None:
|
||||
# depending on the current data style, certain fields are disabled
|
||||
@ -1253,10 +1245,9 @@ Have fun!
|
||||
# otherwise, we need to check for, and clear, other primaries with same role
|
||||
role = str(self.twCredits.item(row, 1).text())
|
||||
r = 0
|
||||
while r < self.twCredits.rowCount():
|
||||
for r in range(self.twCredits.rowCount()):
|
||||
if self.twCredits.item(r, 0).text() != "" and str(self.twCredits.item(r, 1).text()).lower() == role.lower():
|
||||
self.twCredits.item(r, 0).setText("")
|
||||
r = r + 1
|
||||
|
||||
# Now set our new primary
|
||||
self.twCredits.item(row, 0).setText("Yes")
|
||||
|
@ -397,8 +397,7 @@ class VolumeSelectionWindow(QtWidgets.QDialog):
|
||||
|
||||
self.twList.setSortingEnabled(False)
|
||||
|
||||
while self.twList.rowCount() > 0:
|
||||
self.twList.removeRow(0)
|
||||
self.twList.setRowCount(0)
|
||||
|
||||
row = 0
|
||||
for record in self.cv_search_results:
|
||||
|
Loading…
Reference in New Issue
Block a user