Recent

Author Topic: GTK2 : assertion 'GTK_IS_WIDGET (widget)' failed for TTabControl  (Read 919 times)

Nel_Fie

  • Jr. Member
  • **
  • Posts: 57
GTK2 : assertion 'GTK_IS_WIDGET (widget)' failed for TTabControl
« on: February 18, 2025, 07:23:30 pm »
This morning, a bug suddenly appeared out of nowhere in a little graphical application I wrote: it contains a TTabControl, and clicking any of its tabs causes the app to freeze up. The TTabControl is nested in a TNoteBook page via a dynamically created TFrame. Interacting with anything else in the app works without issue. Clicking any tab a second time causes an external SIGSEGV error, with the console message:

Quote
Gtk-CRITICAL **: 19:01:58.732: IA__gtk_widget_child_focus: assertion 'GTK_IS_WIDGET (widget)' failed

In addition, the call stack traces the error to gtk2pagecontrol.inc, line 37 (which is line 7 in the quote below).

Code: Pascal  [Select][+][-]
  1. // this was created as a workaround of a tnotebook eating rightclick of custom controls
  2. function Notebook_Button_Press(widget:PGtkWidget; event:PGdkEventButton):gboolean; cdecl;
  3. begin
  4.   Result := True;
  5.   if gtk_get_event_widget(PGdkEvent(event)) <> widget then exit;
  6.   if OldNoteBookButtonPress = nil then exit;
  7.   Result := OldNoteBookButtonPress(widget, event);
  8. end;  

I haven't managed to reproduce the issue yet, which is why I'm asking here rather than posting it on GitLab. Any idea what the cause is, and how I could potentially solve it? It's all the more baffling since the app was compiled as it is a while ago, so it can't be caused by me changing anything in the code. My best guess is that it's due to a recent update to GTK2 as part of a regular Ubuntu update?

## Lazarus Info:
Lazarus 3.99 (rev main_3_99-2836-gdfce0d15a4)
FPC 3.3.1
x86_64-linux-gtk2

## System Info:
- **Firmware Version:**                            F6
- **OS Name:**                                     Ubuntu 24.04.2 LTS
- **OS Build:**                                    (null)
- **OS Type:**                                     64-bit
- **GNOME Version:**                               46
- **Windowing System:**                            X11
- **Kernel Version:**                              Linux 6.8.0-53-generic

Nel_Fie

  • Jr. Member
  • **
  • Posts: 57
Re: GTK2 : assertion 'GTK_IS_WIDGET (widget)' failed for TTabControl
« Reply #1 on: February 19, 2025, 11:11:03 am »
For what it's worth, I've installed the current Lazarus+FPC 3.9+fixes version (Lazarus 3.9 (rev lazarus_3_8-15-g796a8090d4) FPC 3.2.3 x86_64-linux-gtk2) via FPCUPDeluxe and the error occurs there as well.

Additionally, I tested the GTK3 alpha, and it also causes an error, although (and probably obviously) at a different location: it points to gtk3object.inc, line 86, which calls "gtk_main_do_event(AEvent);" in "procedure Gtk3MainEventLoop(AEvent: PGdkEvent; {%H-}AData: gPointer); cdecl;".

I also tested the app with QT5, and strangely enough something similar occurs: no error, but tabs in the TTabControl don't react. Everything else works though, weirdly. So apparently it's not a pure GTK issue, but something else, maybe in how components are arranged in the compiled app?
 

 

TinyPortal © 2005-2018