mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-28 07:51:27 +00:00
lightning_channels_list: use signals to avoid segfault
This commit is contained in:
parent
aaa67adb5a
commit
caadc5a5bb
1 changed files with 14 additions and 0 deletions
|
@ -4,6 +4,7 @@ from PyQt5 import QtCore, QtWidgets
|
|||
from collections import OrderedDict
|
||||
import logging
|
||||
from electrum.lightning import lightningCall
|
||||
import traceback
|
||||
|
||||
mapping = {0: "channel_point"}
|
||||
revMapp = {"channel_point": 0}
|
||||
|
@ -39,6 +40,8 @@ def clickHandler(nodeIdInput, local_amt_inp, push_amt_inp, lightningRpc):
|
|||
lightningCall(lightningRpc, "openchannel")(str(nodeId), local_amt_inp.text(), push_amt_inp.text())
|
||||
|
||||
class LightningChannelsList(QtWidgets.QWidget):
|
||||
update_rows = QtCore.pyqtSignal(str, dict)
|
||||
|
||||
def create_menu(self, position):
|
||||
menu = QtWidgets.QMenu()
|
||||
cur = self._tv.currentItem()
|
||||
|
@ -67,6 +70,15 @@ class LightningChannelsList(QtWidgets.QWidget):
|
|||
except KeyError:
|
||||
obj[k] = v
|
||||
def lightningRpcHandler(self, methodName, obj):
|
||||
if isinstance(obj, Exception):
|
||||
try:
|
||||
raise obj
|
||||
except:
|
||||
traceback.print_exc()
|
||||
else:
|
||||
self.update_rows.emit(methodName, obj)
|
||||
|
||||
def do_update_rows(self, methodName, obj):
|
||||
if methodName != "listchannels":
|
||||
print("channel list ignoring reply {} to {}".format(obj, methodName))
|
||||
return
|
||||
|
@ -78,6 +90,8 @@ class LightningChannelsList(QtWidgets.QWidget):
|
|||
def __init__(self, parent, lightningWorker, lightningRpc):
|
||||
QtWidgets.QWidget.__init__(self, parent)
|
||||
|
||||
self.update_rows.connect(self.do_update_rows)
|
||||
|
||||
def tick():
|
||||
lightningCall(lightningRpc, "listchannels")()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue