Skip to content

Commit

Permalink
[Qt] Nits when using currentItem() -- make sure it's not None
Browse files Browse the repository at this point in the history
This is in the spirit of the previous commit, 86b8a80
  • Loading branch information
cculianu committed Apr 6, 2019
1 parent 86b8a80 commit 423785e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions gui/qt/network_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ def create_menu(self, position):

def keyPressEvent(self, event):
if event.key() in [ Qt.Key_F2, Qt.Key_Return ]:
self.on_activated(self.currentItem(), self.currentColumn())
item, col = self.currentItem(), self.currentColumn()
if item and col > -1:
self.on_activated(item, col)
else:
QTreeWidget.keyPressEvent(self, event)

Expand Down Expand Up @@ -212,7 +214,9 @@ def set_server(self, s):

def keyPressEvent(self, event):
if event.key() in [ Qt.Key_F2, Qt.Key_Return ]:
self.on_activated(self.currentItem(), self.currentColumn())
item, col = self.currentItem(), self.currentColumn()
if item and col > -1:
self.on_activated(item, col)
else:
QTreeWidget.keyPressEvent(self, event)

Expand Down
4 changes: 3 additions & 1 deletion gui/qt/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,9 @@ def editItem(self, item, column):

def keyPressEvent(self, event):
if event.key() in [ Qt.Key_F2, Qt.Key_Return ] and self.editor is None:
self.on_activated(self.currentItem(), self.currentColumn())
item, col = self.currentItem(), self.currentColumn()
if item and col > -1:
self.on_activated(item, col)
else:
QTreeWidget.keyPressEvent(self, event)

Expand Down

0 comments on commit 423785e

Please sign in to comment.