qml: destroy qeswaphelper with SwapDialog and catch RuntimeErrors if qeswalhelper members are accessed after
This commit is contained in:
@@ -365,7 +365,10 @@ ApplicationWindow
|
|||||||
Component {
|
Component {
|
||||||
id: swapDialog
|
id: swapDialog
|
||||||
SwapDialog {
|
SwapDialog {
|
||||||
onClosed: destroy()
|
onClosed: {
|
||||||
|
swaphelper.destroy()
|
||||||
|
destroy()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -359,12 +359,16 @@ class QESwapHelper(AuthMixin, QObject, QtEventListener):
|
|||||||
fut = asyncio.run_coroutine_threadsafe(coro, loop)
|
fut = asyncio.run_coroutine_threadsafe(coro, loop)
|
||||||
self.swapStarted.emit()
|
self.swapStarted.emit()
|
||||||
txid = fut.result()
|
txid = fut.result()
|
||||||
self.swapSuccess.emit()
|
try: # swaphelper might be destroyed at this point
|
||||||
|
self.swapSuccess.emit()
|
||||||
|
except RuntimeError:
|
||||||
|
pass
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.error(str(e))
|
try: # swaphelper might be destroyed at this point
|
||||||
self.swapFailed.emit(str(e))
|
self._logger.error(str(e))
|
||||||
finally:
|
self.swapFailed.emit(str(e))
|
||||||
self.deleteLater()
|
except RuntimeError:
|
||||||
|
pass
|
||||||
|
|
||||||
threading.Thread(target=swap_task, daemon=True).start()
|
threading.Thread(target=swap_task, daemon=True).start()
|
||||||
|
|
||||||
@@ -383,15 +387,19 @@ class QESwapHelper(AuthMixin, QObject, QtEventListener):
|
|||||||
fut = asyncio.run_coroutine_threadsafe(coro, loop)
|
fut = asyncio.run_coroutine_threadsafe(coro, loop)
|
||||||
self.swapStarted.emit()
|
self.swapStarted.emit()
|
||||||
success = fut.result()
|
success = fut.result()
|
||||||
if success:
|
try: # swaphelper might be destroyed at this point
|
||||||
self.swapSuccess.emit()
|
if success:
|
||||||
else:
|
self.swapSuccess.emit()
|
||||||
self.swapFailed.emit('')
|
else:
|
||||||
|
self.swapFailed.emit('')
|
||||||
|
except RuntimeError:
|
||||||
|
pass
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.error(str(e))
|
try: # swaphelper might be destroyed at this point
|
||||||
self.swapFailed.emit(str(e))
|
self._logger.error(str(e))
|
||||||
finally:
|
self.swapFailed.emit(str(e))
|
||||||
self.deleteLater()
|
except RuntimeError:
|
||||||
|
pass
|
||||||
|
|
||||||
threading.Thread(target=swap_task, daemon=True).start()
|
threading.Thread(target=swap_task, daemon=True).start()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user