WARNING ** Trying to snapshot GtkGizmo

Hello all,

When I run the following and write/erase/press return or backspace constantly, I receive the following ;

(process:3131): Gtk-WARNING **: 19:54:06.250: Trying to snapshot GtkGizmo 0x1468390 without a current allocation

static GMainLoop *main_loop;

int main (int argc, char *argv[])
{

GtkWidget *window;
GtkSourceView *view;
GtkScrolledWindow *scroll;

main_loop = g_main_loop_new (NULL, FALSE);

	gtk_init ();
	gtk_source_init ();

	window = gtk_window_new ();	
	view = GTK_SOURCE_VIEW (gtk_source_view_new());    
	gtk_source_view_set_show_line_numbers(view, true);
	gtk_window_set_default_size (GTK_WINDOW (window), 900, 600);
	gtk_window_set_title (GTK_WINDOW (window), "GtkSourceView Test");

	g_signal_connect_swapped (window, "destroy", G_CALLBACK (g_main_loop_quit), main_loop);
	
	scroll =  GTK_SCROLLED_WINDOW(gtk_scrolled_window_new ());
	gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW(scroll),  GTK_WIDGET(view));

    gtk_window_set_child(GTK_WINDOW(window), GTK_WIDGET(scroll));
    gtk_widget_set_visible(window, true);	
    gtk_source_finalize ();
    g_main_loop_run (main_loop);
    return(0);

After some searching I realized that the warning occurs when I try to update something that isn’t there as an object but could not dig any further. Do you guys have any idea how I might resolve or get over this warning ? Do you see something wrong with the above implementation or it’s my Gtk and GtkSource setup ?

Thank you,

Hi,

First, make sure you call “finalize” at the very end only, i.e. after the main loop:

    g_main_loop_run (main_loop);
    gtk_source_finalize ();
    return(0);

If it doesn’t help, can you give us the exact versions of the gtk and gtksourceview you’re using?
(the latest stable ones should be gtk-4.12.5 and gtksourceview-5.10)

side note:

prefer
gtk_window_present (GTK_WINDOW(window));
instead of
gtk_widget_set_visible (window, true);

for displaying a window.

I still get the warning after suggested preferences.

gtk > 4.12.4
gtksourceview > 5.0.0

do you think I should update sourceview ?

On the other hand I discovered that warning occurs when scrolledwindow is needed to be scrolled by itself

Ah, I saw the warning on my side too.

I launched the debugger, it’s not raised by gtksourceview but by the GtkScrollbar widget.
Doesn’t look harmful, probably some race condition.

1 Like

Might be, thank you for testing it out.

Hello… we are working on a major GTK4 application that uses GtkSourceView 5.0 as well and we are experiencing this same error message when we do the following.

I am VERY interested on picking up any fix to this issue and will rebuild GtkSourceView once the fix is available. Thanks.

========================================== (Issue documented below) ===========

I have a text file that I paste a few hundred lines of text into. Whenever I do this for the first time in an instance of using Editor, I get the following warning:

*(Editor:287205): Gtk-WARNING *: 15:45:16.432: Trying to snapshot GtkGizmo 0x25f2940 without a current allocation

When I paste the same text again, the warning doesn’t appear right away. I’ll get the warning again eventually as I paste more text though. For example, I might get the warning at 100 lines of text, then 10,000, then 100,000.

OH… by the way, here is my development environment (RHEL 9.3)
meson ================= > 1.2.2
glib-2.0 ===============> 2.78.0
cairo ==================> 1.18.0
gobject-introspection ==> 1.78.1
gdk-pixbuf-2.0 =========> 2.42.10
gtk-doc ================> 1.33.1
pango ==================> 1.51.0
graphene-1.0 ===========> 1.10.8
harfbuzz ===============> 8.2.1
wayland-scanner ========> 1.22.0
gstreamer-1.0 ==========> 1.23.0.1
libsoup-3.0 ============> 3.4.3
wpe-1.0 ================> 1.15.1
wpebackend-fdo-1.0 =====> 1.14.2
atk ====================> 2.38.0
gudev-1.0 ==============> 238
manette-0.2 ============> 0.2.6
libsecret-1 ============> 0.21.1
libxslt ================> 1.1.38
gtk4 ===================> 4.13.7
pkg-config --listall | grep gtk4 =========>
gtk4-atspi GTK - GTK AT-SPI accessibility support
gtk4-wayland GTK - GTK Graphical UI Library
gtk4-unix-print GTK - GTK Unix print support
gtk4-x11 GTK - GTK Graphical UI Library
gtk4 GTK - GTK Graphical UI Library
gtk4-atspi GTK - GTK AT-SPI accessibility support
gtk4-wayland GTK - GTK Graphical UI Library
gtk4-unix-print GTK - GTK Unix print support
gtk4-x11 GTK - GTK Graphical UI Library
gtk4 GTK - GTK Graphical UI Library
gtksourceview-5 ========> 5.10.0

Hi,

As said above:

  • this has nothing to do with gtksourceview. It’s on gtk4 side, when a content becomes scrollable (like after pasting a big text) the vertical scrollbar activates and emits this warning on 1st appearance.
  • it’s just a warning, nothing broken (although could be improved), can be safely ignored.

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