Re: Error in a simple GTK program



Hi;

please, use the "gtk" tag on Discourse for asking questions about GTK:

  https://discourse.gnome.org

On Thu, 21 May 2020 at 19:33, Alex Tuchin via gnome-devel-list <gnome-devel-list gnome org> wrote:
 

  label = gtk_label_new ("Look at my color!");
  gtk_widget_override_color(label, GTK_STATE_NORMAL, &rgba);


You should not do this. The override_color() method is deprecated, and it's generally broken to mix GTK2-style overrides with GTK3 CSS-based style definitions. While it might be working in very limited scenarios, it's bound to break.
 
  g_signal_connect (G_OBJECT (button), "color_set", G_CALLBACK (color_changed), (gpointer) label);

The casts, aside from `G_CALLBACK` are unnecessary.
 
  hbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);

You should be more careful when it comes to naming your variables; an "hbox" with a vertical orientation is kind of wrong.
 
When I click on the button and start in terminal mode, an error appears "(cbGtkStudyWin.exe:1644): Gtk-CRITICAL **: gtk_box_reorder_child: assertion `GTK_IS_WIDGET (child)' failed". I looked through the entire code several times, but still did not understand, because of which an error occurs. Please help me figure it out.

There is nothing in your code that could cause that warning, so either the code you're running is not exactly the one you posted, or there's something else that's broken.

You should run your code under a debugger, and set the `G_DEBUG=fatal-criticals` environment variable so that the first critical warning will hit a breakpoint that you can inspect.

Ciao,
 Emmanuele.

--


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]