From 88efb92c15b563188987c41c697875c340dd72a4 Mon Sep 17 00:00:00 2001 From: themighty1 Date: Mon, 20 Oct 2014 18:45:53 +0300 Subject: [PATCH] dont freeze UI when mass-marking unread --- src/bitmessageqt/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index df6b3b45..1c1c08a6 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -2663,15 +2663,19 @@ class MyForm(QtGui.QMainWindow): def on_action_InboxMarkUnread(self): font = QFont() font.setBold(True) + inventoryHashesToMarkUnread = [] for row in self.ui.tableWidgetInbox.selectedIndexes(): currentRow = row.row() inventoryHashToMarkUnread = str(self.ui.tableWidgetInbox.item( currentRow, 3).data(Qt.UserRole).toPyObject()) - sqlExecute('''UPDATE inbox SET read=0 WHERE msgid=?''', inventoryHashToMarkUnread) + inventoryHashesToMarkUnread.append(inventoryHashToMarkUnread) self.ui.tableWidgetInbox.item(currentRow, 0).setFont(font) self.ui.tableWidgetInbox.item(currentRow, 1).setFont(font) self.ui.tableWidgetInbox.item(currentRow, 2).setFont(font) self.ui.tableWidgetInbox.item(currentRow, 3).setFont(font) + #sqlite requires the exact number of ?s to prevent injection + sqlExecute('''UPDATE inbox SET read=0 WHERE msgid IN (%s)''' % ( + "?," * len(inventoryHashesToMarkUnread))[:-1], *inventoryHashesToMarkUnread) self.changedInboxUnread() # self.ui.tableWidgetInbox.selectRow(currentRow + 1) # This doesn't de-select the last message if you try to mark it unread, but that doesn't interfere. Might not be necessary.