Merge pull request #51 from status-im/fix/crash-on-emit-with-null

fix(qobject): Crash on signal emit with null vptr
This commit is contained in:
Alex Jbanca 2023-06-27 10:46:10 +03:00 committed by GitHub
commit 06a6c70404
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -23,6 +23,9 @@ method metaObject*(self: QObject): QMetaObject {.base.} =
QObject.staticMetaObject
proc emit*(qobject: QObject, signalName: string, arguments: openarray[QVariant] = []) =
if qobject.vptr.isNil:
return
## Emit the signal with the given name and values
var dosArguments: seq[DosQVariant] = @[]
for argument in arguments:
@ -73,4 +76,4 @@ proc vptr*(self: QObject): DosQObject =
result = self.vptr
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)