Re: Error in a simple GTK program
Emmanuele Bassi via gnome-devel-list <[email protected]> Thu, 21 May 2020 19:49:39 +0100
| Newsgroups | gmane.comp.gnome.devel |
|---|---|
| Message-ID | <CALnHYQEq9xTgJP2vA1EriqThjqkCTL1vJefw8A9z=v4YM-32xQ@mail.gmail.com> |
--===============6852023475337530363== Content-Type: multipart/alternative; boundary="0000000000003a288905a62cfaee" --0000000000003a288905a62cfaee Content-Type: text/plain; charset="UTF-8" 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 < [email protected]> 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. -- https://www.bassi.io [@] ebassi [@gmail.com] --0000000000003a288905a62cfaee Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr"><div>Hi;</div><div><br></div><div>please,= use the "gtk" tag on Discourse for asking questions about GTK:</= div><div><br></div><div>=C2=A0 <a href=3D"https://discourse.gnome.org">http= s://discourse.gnome.org</a></div></div><br><div class=3D"gmail_quote"><div = dir=3D"ltr" class=3D"gmail_attr">On Thu, 21 May 2020 at 19:33, Alex Tuchin = via gnome-devel-list <<a href=3D"mailto:[email protected]">gnom= [email protected]</a>> wrote:<br></div><div>=C2=A0</div><blockquote= class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px so= lid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><br><div>=C2=A0 lab= el =3D gtk_label_new ("Look at my color!");<br>=C2=A0 gtk_widget_= override_color(label, GTK_STATE_NORMAL, &rgba);<br><br></div></div></bl= ockquote><div><br></div><div>You should not do this. The override_color() m= ethod is deprecated, and it's generally broken to mix GTK2-style overri= des with GTK3 CSS-based style definitions. While it might be working in ver= y limited scenarios, it's bound to break.<br></div><div>=C2=A0</div><bl= ockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-lef= t:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div>=C2=A0= g_signal_connect (G_OBJECT (button), "color_set", G_CALLBACK (co= lor_changed), (gpointer) label);<br></div></div></blockquote><div><br></div= ><div>The casts, aside from `G_CALLBACK` are unnecessary.<br></div><div>=C2= =A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8e= x;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"= ><div>=C2=A0 hbox =3D gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);<br></div><= /div></blockquote><div><br></div><div>You should be more careful when it co= mes to naming your variables; an "hbox" with a vertical orientati= on is kind of wrong.<br></div><div>=C2=A0</div><blockquote class=3D"gmail_q= uote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,2= 04);padding-left:1ex"><div dir=3D"ltr"><div>When I click on the button and = start in terminal mode, an error appears "(cbGtkStudyWin.exe:1644): Gt= k-CRITICAL **: gtk_box_reorder_child: assertion `GTK_IS_WIDGET (child)'= failed".=C2=A0I looked through the entire code several times, but sti= ll did not understand, because of which an error occurs. Please help me fig= ure it out.</div></div></blockquote><div><br></div><div>There is nothing in= your code that could cause that warning, so either the code you're run= ning is not exactly the one you posted, or there's something else that&= #39;s broken.</div><div><br></div><div>You should run your code under a deb= ugger, and set the `G_DEBUG=3Dfatal-criticals` environment variable so that= the first critical warning will hit a breakpoint that you can inspect.<br>= </div><div><br></div><div>Ciao,</div><div>=C2=A0Emmanuele.<br></div></div><= br>-- <br><div dir=3D"ltr" class=3D"gmail_signature"><a href=3D"https://www= .bassi.io" target=3D"_blank">https://www.bassi.io</a><br>[@] ebassi [@<a hr= ef=3D"http://gmail.com" target=3D"_blank">gmail.com</a>]</div></div> --0000000000003a288905a62cfaee-- --===============6852023475337530363== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ gnome-devel-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/gnome-devel-list --===============6852023475337530363==--