Qt swap dialog: do not call update() from the asyncio thread. Fixes some segfaults that were triggered by opening the dialog
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
from typing import TYPE_CHECKING, Optional
|
from typing import TYPE_CHECKING, Optional
|
||||||
|
|
||||||
|
from PyQt5.QtCore import pyqtSignal
|
||||||
from PyQt5.QtWidgets import QLabel, QVBoxLayout, QGridLayout, QPushButton
|
from PyQt5.QtWidgets import QLabel, QVBoxLayout, QGridLayout, QPushButton
|
||||||
|
|
||||||
from electrum.i18n import _
|
from electrum.i18n import _
|
||||||
@@ -26,6 +27,7 @@ Do you want to continue?
|
|||||||
class SwapDialog(WindowModalDialog):
|
class SwapDialog(WindowModalDialog):
|
||||||
|
|
||||||
tx: Optional[PartialTransaction]
|
tx: Optional[PartialTransaction]
|
||||||
|
update_signal = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, window: 'ElectrumWindow'):
|
def __init__(self, window: 'ElectrumWindow'):
|
||||||
WindowModalDialog.__init__(self, window, _('Submarine Swap'))
|
WindowModalDialog.__init__(self, window, _('Submarine Swap'))
|
||||||
@@ -83,6 +85,7 @@ class SwapDialog(WindowModalDialog):
|
|||||||
self.ok_button.setDefault(True)
|
self.ok_button.setDefault(True)
|
||||||
self.ok_button.setEnabled(False)
|
self.ok_button.setEnabled(False)
|
||||||
vbox.addLayout(Buttons(CancelButton(self), self.ok_button))
|
vbox.addLayout(Buttons(CancelButton(self), self.ok_button))
|
||||||
|
self.update_signal.connect(self.update)
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def fee_slider_callback(self, dyn, pos, fee_rate):
|
def fee_slider_callback(self, dyn, pos, fee_rate):
|
||||||
@@ -211,7 +214,7 @@ class SwapDialog(WindowModalDialog):
|
|||||||
if not self.network:
|
if not self.network:
|
||||||
self.window.show_error(_("You are offline."))
|
self.window.show_error(_("You are offline."))
|
||||||
return
|
return
|
||||||
self.window.run_coroutine_from_thread(self.swap_manager.get_pairs(), lambda x: self.update())
|
self.window.run_coroutine_from_thread(self.swap_manager.get_pairs(), lambda x: self.update_signal.emit())
|
||||||
if not self.exec_():
|
if not self.exec_():
|
||||||
return
|
return
|
||||||
if self.is_reverse:
|
if self.is_reverse:
|
||||||
|
|||||||
Reference in New Issue
Block a user