commit 554cf91cffd450df3755462e19deb8d3ffe389a7
parent 0fbcb8229b58b974dec63beaae472c831d993b21
Author: ThomasV <thomasv@electrum.org>
Date: Fri, 23 Feb 2018 12:10:30 +0100
Merge pull request #3599 from SomberNight/fix_wrapped_c_object_has_been_deleted
fix some crashes when the underlying QT (C/C++) object no longer exists
Diffstat:
2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
@@ -2124,7 +2124,12 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
task = partial(self.wallet.sign_message, address, message, password)
def show_signed_message(sig):
- signature.setText(base64.b64encode(sig).decode('ascii'))
+ try:
+ signature.setText(base64.b64encode(sig).decode('ascii'))
+ except RuntimeError:
+ # (signature) wrapped C/C++ object has been deleted
+ pass
+
self.wallet.thread.add(task, on_success=show_signed_message)
def do_verify(self, address, message, signature):
@@ -2188,7 +2193,15 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
return
cyphertext = encrypted_e.toPlainText()
task = partial(self.wallet.decrypt_message, pubkey_e.text(), cyphertext, password)
- self.wallet.thread.add(task, on_success=lambda text: message_e.setText(text.decode('utf-8')))
+
+ def setText(text):
+ try:
+ message_e.setText(text.decode('utf-8'))
+ except RuntimeError:
+ # (message_e) wrapped C/C++ object has been deleted
+ pass
+
+ self.wallet.thread.add(task, on_success=setText)
def do_encrypt(self, message_e, pubkey_e, encrypted_e):
message = message_e.toPlainText()
diff --git a/gui/qt/util.py b/gui/qt/util.py
@@ -410,11 +410,15 @@ class MyTreeWidget(QTreeWidget):
def editItem(self, item, column):
if column in self.editable_columns:
- self.editing_itemcol = (item, column, item.text(column))
- # Calling setFlags causes on_changed events for some reason
- item.setFlags(item.flags() | Qt.ItemIsEditable)
- QTreeWidget.editItem(self, item, column)
- item.setFlags(item.flags() & ~Qt.ItemIsEditable)
+ try:
+ self.editing_itemcol = (item, column, item.text(column))
+ # Calling setFlags causes on_changed events for some reason
+ item.setFlags(item.flags() | Qt.ItemIsEditable)
+ QTreeWidget.editItem(self, item, column)
+ item.setFlags(item.flags() & ~Qt.ItemIsEditable)
+ except RuntimeError:
+ # (item) wrapped C/C++ object has been deleted
+ pass
def keyPressEvent(self, event):
if event.key() in [ Qt.Key_F2, Qt.Key_Return ] and self.editor is None: