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

GTK Assertion Fails calling NewConstraint #95

Open
Matir opened this issue Feb 18, 2023 · 3 comments
Open

GTK Assertion Fails calling NewConstraint #95

Matir opened this issue Feb 18, 2023 · 3 comments

Comments

@Matir
Copy link

Matir commented Feb 18, 2023

When trying to build a constraint via NewConstraint, a GTK assertion fails:

2023/02/17 23:55:03 Critical: Gtk: gtk_constraint_new: assertion 'target == NULL || GTK_IS_CONSTRAINT_TARGET (target)' failed

This is my attempt at a minimal reproducer:

package main

import (
	"os"

	gio "github.com/diamondburned/gotk4/pkg/gio/v2"
	gtk "github.com/diamondburned/gotk4/pkg/gtk/v4"
)

func main() {
	app := gtk.NewApplication("com.example", gio.ApplicationFlagsNone)
	app.ConnectActivate(func() {
		foo := gtk.NewLabel("foo")
		bar := gtk.NewLabel("bar")
		box := gtk.NewBox(gtk.OrientationVertical, 0)
		box.Append(foo)
		box.Append(bar)
		layout := gtk.NewConstraintLayout()
		box.SetLayoutManager(layout)
		con := gtk.NewConstraint(
			foo, gtk.ConstraintAttributeLeft, gtk.ConstraintRelationEq, box, gtk.ConstraintAttributeLeft, 1.0, 0.0, 1)
		layout.AddConstraint(con)
		win := gtk.NewApplicationWindow(app)
		win.SetTitle("ConstraintLayout test")
		win.SetChild(box)
		win.Show()
	})
	app.Run(os.Args)
}

As far as I can tell, all Widget should be valid instances of ConstraintTargeter. I notice the generated code has this very confusing type conversion to the C type, I'm afraid I'm not able to follow what's going on here:

_arg1 = *(*C.gpointer)(unsafe.Pointer(coreglib.InternObject(target).Native()))
@diamondburned
Copy link
Owner

_arg1 = *(*C.gpointer)(unsafe.Pointer(coreglib.InternObject(target).Native()))

Er, I don't think the codegen did a correct job here. Why is it dereferencing a GObject pointer?

The code generator is a mess right now, especially if you use the main branch. A lot of the code has been rusted out of my mind ever since my effort to add libgirepository into the code generator started :(

@Matir
Copy link
Author

Matir commented Feb 19, 2023

Is there a branch/tag you'd recommend using?

@diamondburned
Copy link
Owner

Is there a branch/tag you'd recommend using?

Other than the latest release, unfortunately not. The generator will just have to be fixed.

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