Gtk4 Stack and Box - after append can now longer update the stack (original) (raw)
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?
gwillems March 27, 2024, 9:33pm 2
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.
foodmonkey (greg simpson) April 2, 2024, 12:08pm 3
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…
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.
system (system) Closed April 18, 2024, 8:47am 5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.