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

Let Crystal user objects be created from g_gobject_new calls. #153

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Commits on Jun 28, 2024

  1. Let Crystal user objects be created from g_gobject_new calls.

    This is a breaking change, since it now requires all GObject subclasses
    to have a constructor without arguments.
    
    What changed:
    
    There are 2 thread local variables to inform if the object is being created
    in C land or Crystal land, we store the objects instance pointers there.
    
    When the object is created in C land, the Crystal instance is created on
    GObject instance_init method.
    
    When the object is created in Crystal land, the GObject instance_init method
    creates no Crystal instance.
    
    This also fixes the use case of tryign to use a Crystal defined GObject property
    before the Wrapper gets fully initialized.
    
    Fixes hugopl/gtk4.cr#69
    hugopl committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    8f3a075 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d8297ea View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    de6a787 View commit details
    Browse the repository at this point in the history
  4. Allow Crystal User GObjects to not have a default constructor.

    If the object doens't have a default constructor and someone tries to
    create it from C, a GLib fatal error is issued.
    hugopl committed Jun 28, 2024
    Configuration menu
    Copy the full SHA
    769cdc5 View commit details
    Browse the repository at this point in the history