mirror of https://github.com/status-im/nimqml.git
fix(qobject): Crash on signal emit with null vptr
When the QObject is deleted with dos_qobject_deleteLater the QObject slots will remain active until the event loop finished processing the events. It can trigger another emit, but this time the vptr will be null.
This commit is contained in:
parent
dd5cfe2fae
commit
2fda7de6c5
|
@ -23,6 +23,9 @@ method metaObject*(self: QObject): QMetaObject {.base.} =
|
||||||
QObject.staticMetaObject
|
QObject.staticMetaObject
|
||||||
|
|
||||||
proc emit*(qobject: QObject, signalName: string, arguments: openarray[QVariant] = []) =
|
proc emit*(qobject: QObject, signalName: string, arguments: openarray[QVariant] = []) =
|
||||||
|
if qobject.vptr.isNil:
|
||||||
|
return
|
||||||
|
|
||||||
## Emit the signal with the given name and values
|
## Emit the signal with the given name and values
|
||||||
var dosArguments: seq[DosQVariant] = @[]
|
var dosArguments: seq[DosQVariant] = @[]
|
||||||
for argument in arguments:
|
for argument in arguments:
|
||||||
|
@ -73,4 +76,4 @@ proc vptr*(self: QObject): DosQObject =
|
||||||
result = self.vptr
|
result = self.vptr
|
||||||
|
|
||||||
proc signalConnect*(sender: QObject, signal: string, receiver: QObject, slot: string, signalType: int = 0) =
|
proc signalConnect*(sender: QObject, signal: string, receiver: QObject, slot: string, signalType: int = 0) =
|
||||||
dos_qobject_signal_connect(sender.vptr, ("2" & signal).cstring, receiver.vptr, ("1" & slot).cstring, signalType.cint)
|
dos_qobject_signal_connect(sender.vptr, ("2" & signal).cstring, receiver.vptr, ("1" & slot).cstring, signalType.cint)
|
||||||
|
|
Loading…
Reference in New Issue