allow nil strings for readSlot, writeSlot and notifySlot in registerProperty

This commit is contained in:
Will Szumski 2015-01-12 17:52:22 +00:00
parent 42ded08c7f
commit bba226f550
1 changed files with 6 additions and 1 deletions

View File

@ -411,7 +411,12 @@ proc registerProperty*(qobject: QObject,
writeSlot: string,
notifySignal: string) =
## Register a property in the QObject with the given name and type.
dos_qobject_property_create(qobject.data, propertyName, propertyType.cint, readSlot, writeSlot, notifySignal)
assert propertyName != nil, "property name cannot be nil"
# don't convert a nil string, else we get a strange memory address
let cReadSlot: cstring = if readSlot == nil: cast[cstring](nil) else: readSlot
let cWriteSlot: cstring = if writeSlot == nil: cast[cstring](nil) else: writeSlot
let cNotifySignal: cstring = if notifySignal == nil: cast[cstring](nil) else: notifySignal
dos_qobject_property_create(qobject.data, propertyName, propertyType.cint, cReadSlot, cWriteSlot, cNotifySignal)
proc emit*(qobject: QObject, signalName: string, args: openarray[QVariant] = []) =
## Emit the signal with the given name and values