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

Builder, Dialogs, and SegFaults during garbage collection #306

Open
seeseemelk opened this issue Jul 31, 2020 · 1 comment
Open

Builder, Dialogs, and SegFaults during garbage collection #306

seeseemelk opened this issue Jul 31, 2020 · 1 comment

Comments

@seeseemelk
Copy link

I have an issue that causes my program to crash if a garbage collection cycle is performed after a dialog is closed.
However, the issue only occurs if the dialog contains children that were constructed by a GtkBuilder.

Essentially:

auto dialog = /* create dialog */;
auto builder = /* create builder */;
auto widget = builder.getObject("widget_id");
dialog.getContentArea().add(widget);
dialog.run();
dialog.destroy();
GC.collect(); // Crash here

However, if I add a widget that I created manually, it works perfectly okay.
Moreover, if I change Builder#getObject(string) as follows, the problem disappears:

// gtk.Builder.d: line 779 - 789
public ObjectG getObject(string name)
{
	auto p = gtk_builder_get_object(gtkBuilder, Str.toStringz(name));

	if(p is null)
	{
		return null;
	}

	// Original line:
	//return ObjectG.getDObject!(ObjectG)(cast(GObject*) p);
	// New line:
	return ObjectG.getDObject!(ObjectG)(cast(GObject*) p, true);
}

Is this a bug in GtkD, and if so, is this the correct fix?

@seeseemelk
Copy link
Author

I have found that the change in Builder#getObject causes certain other issues, so it's clearly not a correct fix.
However, changing dialog.getContentArea().add(widget) to dialog.getContentArea().packStart(widget, ...) does fix the problem. Although I still find it odd that the original variant segfaults.

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

1 participant