Trying to snapshot GtkStatusbar Warning?


I am trying to figure out what this may be caused by in my application:
I am getting multiple (11 to be precise) of those messages after a window with a statusbar, a panned view (with a gtkdrawing area and a note book) and a header bar+few button is created – I am not deleting or removing any widgets at this time:

(gxsm4:151092): Gtk-WARNING **: 11:18:51.885: Trying to snapshot GtkStatusbar 0x559a9eda68a0 without a current allocation

But I do send updates/texts to the statusbar (possibly while loading data to be displayed) in this “window” – can there be a conflict of some kind I need to take care of?

If you are doing it from another thread, yes.

The warning may also appear when the parent of the statusbar does not allocate a proper size to its statusbar child. What’s the parent widget of the statusbar?

It’s attached to a grid which is the child of the window:

	statusbar = gtk_statusbar_new ();
	gtk_grid_attach (GTK_GRID (v_grid), statusbar, 1,10, 3,1);

It is attached to the grid early, before several more widgets.

About threads, I am aware of the unfortunate non thread safe behavior of gtk. I mean real g_threads. OK.

But I am still unclear if g_idle or g_timeouts are potentially trouble also?

Both g_idle_add() and g_timeout_add() do not use threads: they schedule the function you pass so that it’s called by the main loop at the appropriate time.

1 Like

Excellent, that confirms my understanding about those and then there is no potential issue related to idle functions I use to do updates on a periodic manner! I designed a kind of state machine for longer tasks which is executed in idle time and processes at every call some work completed quickly – I need to check on hi level instrument status and coordinate jobs.

…parent of the statusbar does not allocate a proper size to its statusbar child.

How shall I understand this? Or what can I do assure it’s good?
Anyhow, I do not see anything strange, the status bar works as intended.

That warning can be caused by a ton of things. It essentially means that the status bar was not given a proper size by the parent widget before the rendering part of the current frame, or that the required size of the status bar changed after it already got a proper size.
We can’t say for sure what’s going wrong in your case exactly.

If you can come up with a standalone reproducer that exhibits the same problem, that would help.

1 Like

OK I understand.

I tried to reproduced in a minimal application but can not generate the warning in a simple context.

With a little more looking at it and debugging I tracked it down to the status updates I push when loading data/image and creating three “On Screen Info” info markers within my drawing area. And when setting those up one by one their coordinates are updated and supposed to be shown in the status bar in a quick consecutive order – not that I would read it anyway at this time – but the object is doing that when activated or created.
And I find it is not shown at load time – unless I later touch/move them with the mouse manually, then all is fine.

In case there may be a hint, the “load” is executed via a callback triggered by a file dialog response – or via a drag-and-drop controller action. Both cases are triggering the warning.

            g_signal_connect (chooser, "response",
                              G_CALLBACK (Surface::load_exec),

Also all is good when I manually add / create a new object a like, no warning.
Object add triggered via drawing area gesture triggered events.

As this is a large application I sure not expect anyone to look into details or code (unless curious, it is open source but has a few dependencies beyond gtk4, ninja build compatible now :slight_smile:
[ GXSM / Gxsm SVN repository / [r5721] /trunk/Gxsm4 ]
$$$ svn checkout gxsm4svn

For illustration I captured a quick screen recording of it:

Anyhow, thanks for your comments and thoughts, very helpful porting and sorting out potential issues.

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