andy128k / cl-gobject-introspection

BSD 2-Clause "Simplified" License
49 stars 15 forks source link

Function call wrongly returns NIL when ownership stays with the foreign part of the code #81

Closed igorcalabria closed 3 years ago

igorcalabria commented 3 years ago

If free-from-foreign is false, mem-get will return NIL when it should return the actual object: https://github.com/andy128k/cl-gobject-introspection/blob/master/src/function.lisp#L312

Here's my fix

          (if-let ((obj (build-object-ptr gir-class ptr)))
            (if free-from-foreign
                (object-setup-gc obj :everything)
                obj))))))

I think this was just a small mistake with the position of obj, since it was on the ELSE-FORM of the if-let macro. If this was a plain "let", the previous version would be just fine since obj would be returned either way.

andy128k commented 3 years ago

Thanks a lot!