fix(@desktop): crash on shutdown

This commit is contained in:
Andrei Smirnov 2021-08-06 13:08:24 +03:00 committed by Iuri Matias
parent 7df028df77
commit 51c5a8015d
1 changed files with 5 additions and 3 deletions

View File

@ -19,7 +19,6 @@ import ./status/tasks/marathon/mailserver/controller as mailserver_controller
import ./status/tasks/marathon/mailserver/worker as mailserver_worker
var signalsQObjPointer: pointer
var mailserverQObjPointer: pointer
logScope:
topics = "main"
@ -112,7 +111,9 @@ proc mainProc() =
netAccMgr.setNetworkAccessible(NetworkAccessibility.Accessible)
let signalController = signals.newController(status)
defer: signalController.delete()
defer:
signalsQObjPointer = nil
signalController.delete()
# We need this global variable in order to be able to access the application
# from the non-closure callback passed to `libstatus.setSignalEventCallback`
@ -227,6 +228,7 @@ proc mainProc() =
# it will be passed as a regular C function to libstatus. This means that
# we cannot capture any local variables here (we must rely on globals)
var callback: SignalCallback = proc(p0: cstring) {.cdecl.} =
if signalsQObjPointer != nil:
signal_handler(signalsQObjPointer, p0, "receiveSignal")
status_go.setSignalEventCallback(callback)