- ;; Extract initargs which we should pass directly to the GObeject
- ;; constructor
- (let* ((slotds (class-slots (class-of object)))
- (args (loop
- as tmp = initargs then (cddr tmp) while tmp
- as key = (first tmp)
- as value = (second tmp)
- as slotd = (find-if
- #'(lambda (slotd)
- (member key (slot-definition-initargs slotd)))
- slotds)
- when (and (typep slotd 'effective-property-slot-definition)
- (slot-value slotd 'construct))
- collect (progn
- (remf initargs key)
- (list
- (slot-definition-pname slotd)
- (slot-definition-type slotd)
- value)))))
- (if args
- (let* ((string-size (size-of 'string))
- (string-writer (writer-function 'string))
- (string-destroy (destroy-function 'string))
- (params (allocate-memory
- (* (length args) (+ string-size +gvalue-size+)))))
- (loop
- for (pname type value) in args
- as tmp = params then (sap+ tmp (+ string-size +gvalue-size+))
- do (funcall string-writer pname tmp)
- (gvalue-init (sap+ tmp string-size) type value))
- (unwind-protect
- (setf
- (slot-value object 'location)
- (%gobject-newv (type-number-of object) (length args) params))
+ (unless (slot-boundp object 'location)
+ ;; Extract initargs which we should pass directly to the GObeject
+ ;; constructor
+ (let* ((slotds (class-slots (class-of object)))
+ (args (when initargs
+ (loop
+ as (key value . rest) = initargs then rest
+ as slotd = (find-if
+ #'(lambda (slotd)
+ (member key (slot-definition-initargs slotd)))
+ slotds)
+ when (and (typep slotd 'effective-property-slot-definition)
+ (slot-value slotd 'construct))
+ collect (progn
+ (remf initargs key)
+ (list
+ (slot-definition-pname slotd)
+ (slot-definition-type slotd)
+ value))
+ while rest))))
+ (if args
+ (let* ((string-size (size-of 'string))
+ (string-writer (writer-function 'string))
+ (string-destroy (destroy-function 'string))
+ (params (allocate-memory
+ (* (length args) (+ string-size +gvalue-size+)))))