Gtk4 Stack and Box - after append can now longer update the stack

i create a Gtk Box

create a Gtk Stack and StackSideBar

populate the stack with multiple widgets (in this case multiple Gtk Grid)

before i use Gtk.Box.append to add the stack and sidebar to the box - i can use

Gtk.Stack.get_child_by_name
and then
Gtk.Stack.remove

to remove one of the stack children

afterward

Gtk.Box.append (Gtk.StackSideBar) and
Gtk.Box.append (Gtk.Stack)

the “get_child_by_name” works just fine but the “remove” just puts the app into a tail spin and becomes unresponsive

no errors are thrown by the vala compiler or the build

there doesn’t seem a way to refresh the Gtk.Stack object after it has been added to the box

is this as it should be?

and Gtk.Box doesn’t seem to have any methods to interrogate or manipulate the children inside it

what gives?

Hi,

Can you try replacing the Gtk.StackSideBar by a Gtk.StackSwitcher, just for testing?

If it works with the StackSwitcher then it’s probably the same rootcause as this bug.

yes it is the same problem - thanks

thanks for the confirmation!

There is a MR to fix the issue on gtk side, but it got forgotten since months… :frowning_face:

In the meanwhile, on your side there is a trick to avoid the issue: before calling remove, get a reference to the page (e.g. with Gtk.Stack.get_page), increase the reference count, then remove the child, and finally unref the page.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.