Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation errors when installing with (ql:quickload :cl-gtk4) #8

Closed
bigos opened this issue Mar 4, 2023 · 10 comments
Closed

Compilation errors when installing with (ql:quickload :cl-gtk4) #8

bigos opened this issue Mar 4, 2023 · 10 comments

Comments

@bigos
Copy link

bigos commented Mar 4, 2023

Quicklisp seems to pull your latest code, but it needs more work. I had to comment out the code in 3 places to have a successful compilation.

Also, with gdk moved to the dependency, I have to modify my example code.

But it is a nice project and has good potential.

@bigos
Copy link
Author

bigos commented Mar 5, 2023

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}>

@bohonghuang
Copy link
Owner

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?

@bigos
Copy link
Author

bigos commented Mar 5, 2023

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

@bohonghuang
Copy link
Owner

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.

@bigos
Copy link
Author

bigos commented Mar 5, 2023

How do I do g_object_unref after the change?

@bohonghuang
Copy link
Owner

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))))

@bigos
Copy link
Author

bigos commented Mar 5, 2023

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?

@bohonghuang
Copy link
Owner

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.

@bigos
Copy link
Author

bigos commented Mar 5, 2023

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.

@bigos
Copy link
Author

bigos commented Mar 5, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants