Giter Club home page Giter Club logo

Comments (10)

bigos avatar bigos commented on August 20, 2024 1

I have commented out object unref and the code seems to work.

bigos/Pyrulis@dd9e629

I did not know about not having to copy everything from C code and use g_object_unref. Thank you very much for your help. The code now works, and after your library changes, it needed only small modifications. You may close the issue.

from cl-gtk4.

bigos avatar bigos commented on August 20, 2024

The first error. Other errors are similar.

; caught ERROR:
; READ error during COMPILE-FILE:
;
; Symbol "GLIST-LIST" not found in the GLIB package.
;
; Line: 51, Column: 26, File-Position: 2043
;
; Stream: #<SB-INT:FORM-TRACKING-STREAM for "file /home/jacek/quicklisp/local-projects/cl-gtk4/gtk4.lisp" {10028AE9E3}>

from cl-gtk4.

bohonghuang avatar bohonghuang commented on August 20, 2024

The first error. Other errors are similar.

; caught ERROR:
; READ error during COMPILE-FILE:
;
; Symbol "GLIST-LIST" not found in the GLIB package.
;
; Line: 51, Column: 26, File-Position: 2043
;
; Stream: #<SB-INT:FORM-TRACKING-STREAM for "file /home/jacek/quicklisp/local-projects/cl-gtk4/gtk4.lisp" {10028AE9E3}>

Have you updated cl-glib and cl-gobject-introspection-wrapper?

from cl-gtk4.

bigos avatar bigos commented on August 20, 2024

How do I do it? Looking at the quicklisp folder, I do not see them. Also, it is getting late here; I will respond tomorrow.
/home/jacek/quicklisp/dists/ultralisp/software

from cl-gtk4.

bohonghuang avatar bohonghuang commented on August 20, 2024

How do I do it? Looking at the quicklisp folder, I do not see them. Also, it is getting late here; I will respond tomorrow. /home/jacek/quicklisp/dists/ultralisp/software

Just clone these 2 repositories into quicklisp/local-projects, so that Quicklisp will give priority to loading them.

from cl-gtk4.

bigos avatar bigos commented on August 20, 2024

How do I do g_object_unref after the change?

from cl-gtk4.

bohonghuang avatar bohonghuang commented on August 20, 2024

How do I do g_object_unref after the change?

(ql:quickload :glib.gobject) and use gobj:object-unref, while it's unnecessary and even unsafe to do this manually in most cases:

(loop :repeat 100000
      :do (mapcar (alexandria:rcurry #'gobj:pointer-object 'window) ; This never leaks memory
                  (glib:glist-list (application-windows app))))

from cl-gtk4.

bigos avatar bigos commented on August 20, 2024

I mean places like:
https://github.com/bigos/Pyrulis/blob/8bb8c87cfebc8034824a9bc22200f567d7ad213d/Lisp/cl-gtk4-tictactoe.lisp#L741
https://github.com/bigos/Pyrulis/blob/8bb8c87cfebc8034824a9bc22200f567d7ad213d/Lisp/cl-gtk4-tictactoe.lisp#L668

Some Gtk4 examples require to unref objects.

This is taken from the branch that had to be modified to compile with the new version of cl-gtk4. The old master branch works with older version of cl-gtk4 with my modifications.

It appears the Gtk4 needs it in certain places
https://docs.gtk.org/gobject/method.Object.unref.html
https://stackoverflow.com/questions/69135934/creating-a-simple-menubar-menu-and-menu-item-in-c-using-gtk4

and I do not know how to write working code without calling unref. Do you have any suggestions?

from cl-gtk4.

bohonghuang avatar bohonghuang commented on August 20, 2024

Does the code work without gobj:object-unref? Some C examples of GTK involve it, because C doesn't manage the memory automatically, forcing the programmer to unref a object when it is no longer needed. But Lisp has GC and can unref the unreachable objects at its own, so there is no point invoking gobj:object-unref unless you are interacting with GTK through CFFI.

from cl-gtk4.

bigos avatar bigos commented on August 20, 2024

Good question! The memory management questions: https://docs.gtk.org/gtk4/question_index.html , have interesting comments on the subject. Perhaps the following quote will provide further answers for me. I am new to Gtk4, so some of my questions may be a bit wrong.

The transfer annotations for gobject-introspection that are part of the documentation can provide useful hints for memory handling semantics as well.

from cl-gtk4.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.