-
Notifications
You must be signed in to change notification settings - Fork 9
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
Not maintaining a reference to Objects causes errors #20
Comments
I've done some more investigation, and it seems that similar errors can occur even if the object created is not used in anything. I'm unsure if this is related or a separate issue, so I'm adding it in the comments here instead of editing the original issue. Below is a modified version of the start function which creates a shortcut that is then unused (and hence can be gc'd). (defun start (app)
(let ((window (gtk4:make-application-window :application app))
(unused-shortcut
(gtk4:make-shortcut
:trigger (gtk4:shortcut-trigger-parse-string :string "<Ctrl>C")
:action (gtk4:shortcut-action-parse-string :string "action(window.do_stuff)"))))
(format t "shortcut: ~A~%" unused-shortcut)
(setf (gtk4:window-title window) "Test")
(setf *window* window)
(unless (gtk4:widget-visible-p window)
(gtk4:window-present window)))) Running the script with this modification with this modification resulted in the following output:
|
I'm sorry I'm unable to reproduce the issue you mentioned, but based on my experience, the documentation for the
I suspect that you may be using an older version of cl-gobject-introspection that does not handle object ownership correctly, which can result in some memory issues. Could you please update all the libraries to their latest versions and try again? |
Looks like that was indeed the issue. Worth noting that to get it working, I had to manually clone the latest version - updating the quicklisp and uptralisp dists did not fix the issue on its own. From this I conclude it is likely that the version of Happy to close the issue if you want. |
In sbcl, some (all?) gtk objects seem to requite a persistent reference originating from within the lisp program, otherwise upon garbage collection the object will be deleted (even if there are references to that object from other gtk objects).
To demonstrate the issue I've written a short script (assuming quicklisp is installed).
On my system (intel laptop running Linux/EndeavourOS), executing with
sbcl --load <filename>
results in the following behaviour:By default, after 5 seconds (i.e. when gc is forcibly triggered), the application will report the following error message:
Sometimes, it will drop you into ldb, and sometimes the application crashes outright.
If line
(setf *window* window)
is uncommented, then after 5 seconds the controller will be deleted, so any event (mouse-move, keypress etc.) will result in sbcl reporting the following error:Further, trying to close the window will drop the user into ldb
Finally, if both lines are uncommented, then the application works as expected.
Whether or not this is a bug, I am unsure, but if it is expected behaviour I think it should be documented somewhere.
The text was updated successfully, but these errors were encountered: