From c50c6b9d3c5291c6b5fd726fa46b036300fdc2d6 Mon Sep 17 00:00:00 2001 From: Ivan Holmes Date: Mon, 4 Nov 2019 18:38:52 +0000 Subject: [PATCH] fix crash when 'remove chord' is pressed but there are no chords --- gui.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/gui.py b/gui.py index 1dca7f2..e95b0b4 100755 --- a/gui.py +++ b/gui.py @@ -358,14 +358,15 @@ class DocumentWindow(QMainWindow): self.window.blockChordComboBox.addItems(list(self.chordDict.keys())) def removeChordAction(self): - self.updateChords() + if self.window.chordTableView.selectionModel().hasSelection(): # check for selection + self.updateChords() - row = self.window.chordTableView.selectionModel().currentIndex().row() - self.doc.chordList.pop(row) + row = self.window.chordTableView.selectionModel().currentIndex().row() + self.doc.chordList.pop(row) - self.window.chordTableView.populate(self.doc.chordList) - self.clearChordLineEdits() - self.updateChordDict() + self.window.chordTableView.populate(self.doc.chordList) + self.clearChordLineEdits() + self.updateChordDict() def addChordAction(self): success = False # initialise @@ -421,12 +422,13 @@ class DocumentWindow(QMainWindow): self.window.blockNotesLineEdit.repaint() def removeBlockAction(self): - self.updateBlocks() + if self.window.blockTableView.selectionModel().hasSelection(): # check for selection + self.updateBlocks() - row = self.window.blockTableView.selectionModel().currentIndex().row() - self.doc.blockList.pop(row) + row = self.window.blockTableView.selectionModel().currentIndex().row() + self.doc.blockList.pop(row) - self.window.blockTableView.populate(self.doc.blockList) + self.window.blockTableView.populate(self.doc.blockList) def addBlockAction(self): self.updateBlocks()