SIGSERV while closing last TTabSheet on TPageControl lazarus / 31-LCL ---------------------------------------------------------------------- yuray · 2014-05-28 11:41 Hello. The program stopped working SIGSERV after migrating lazarus 1.0 ->1.2 (on Linux only, on Windows all OK). Test case: Linux 32bit, Debian jessie, Lazarus 1.2, gtk2  2.24.23 Place  TPageControl on a form and create 1 page TTabSheet. Also create event handler: Code: [Select]procedure TForm1.PageControl1MouseUp(Sender: TObject; Button: TMouseButton;   Shift: TShiftState; X, Y: Integer); begin   PageControl1.Pages[0].Destroy; end;    While running click on TTabSheet header I got Quote'External: SIGSEGV'.  В файле '/build/gtk+2.0-GomcuM/gtk+2.0-2.24.23/gtk/gtknotebook.c' на строке 3017: if (!priv->during_detach && The code gtknotebook.c from GTK Code: [Select]static gint gtk_notebook_button_release (GtkWidget      *widget,      GdkEventButton *event) {   GtkNotebook *notebook;   GtkNotebookPrivate *priv;   GtkNotebookPage *page;   if (event->type != GDK_BUTTON_RELEASE)     return FALSE;   notebook = GTK_NOTEBOOK (widget);   priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);   page = notebook->cur_page;   if (!priv->during_detach &&       page->reorderable &&       event->button == priv->pressed_button)     gtk_notebook_stop_reorder (notebook);   if (event->button == notebook->button)     {       stop_scrolling (notebook);       return TRUE;     }   else     return FALSE; }    It is a bug? ---------------------------------------------------------------------- Bart · 2014-05-28 13:34 Quote from: yuray on May 28, 2014, 01:41:45 pmCode: [Select]procedure TForm1.PageControl1MouseUp(Sender: TObject; Button: TMouseButton;   Shift: TShiftState; X, Y: Integer); begin   PageControl1.Pages[0].Destroy; end;    This will SIGSEGV if there are no more pages left, I guess. Bart ---------------------------------------------------------------------- yuray · 2014-05-29 05:06 Quote from: Bart on May 28, 2014, 03:34:26 pmQuote from: yuray on May 28, 2014, 01:41:45 pmCode: [Select]procedure TForm1.PageControl1MouseUp(Sender: TObject; Button: TMouseButton;   Shift: TShiftState; X, Y: Integer); begin   PageControl1.Pages[0].Destroy; end;    This will SIGSEGV if there are no more pages left, I guess. Bart With Lazarus 1.0 its worked. With Lazarus 1.2 its worked on Windows only (because not used GTK?). ---------------------------------------------------------------------- Bart · 2014-05-29 13:43 At that point in time PageControl1.Pages[0] does no longer exist, because there are no more pages once you deleted the last one. You should check that PageControl1 has at least one page before cliing this code. Bart ---------------------------------------------------------------------- yuray · 2014-05-30 07:20 At time to invoke a PageControl1.Pages[0].Destroy the PageControl1.Pages[0] is exist. I create it on design form before. SIGSERV raise not in Destroy function. And again: on Windows this code is worked. ---------------------------------------------------------------------- howardpc · 2014-05-30 07:47 Do you also get a SIGSEGV with Code: [Select]begin   PageControl1.Pages[0].Free; end; ? ---------------------------------------------------------------------- Blaazen · 2014-05-30 08:08 Quote from: howardpc on May 30, 2014, 09:47:14 amDo you also get a SIGSEGV with Code: [Select]begin   PageControl1.Pages[0].Free; end; ? Yes, this crash too (only in GTK2 while in Qt4 it works too). I tried to move the code from PageControlMouseUp to TabSheetMouseUp and it works (i.e. GTK2 is able to delete the last page w/o crash). I guess you need it because of some user-friendly GUI, right? Try this: Code: [Select]if (PageControl1.PageCount>1) or not (Sender is TPageControl) then     PageControl1.Pages[0].Free; as a general mouse up event, where user will have to close the last tab by click on the tab (not the header). You can open a issue, of course. ... I did one more test and it works for PageControlMouseDown. ---------------------------------------------------------------------- taazz · 2014-05-30 08:21 Doesn't GTK2 support the close button on the tabsheets? something that windows does not and thats why you need to monitor clicks and mouse events? ---------------------------------------------------------------------- Blaazen · 2014-05-30 08:36 QuoteDoesn't GTK2 support the close button on the tabsheets? something that windows does not and thats why you need to monitor clicks and mouse events? Yes, it does (it must be set in Options and it must also be done in OnCloseTabClicked: Sender.Free;). ---------------------------------------------------------------------- yuray · 2014-06-02 07:10 Quote from: Blaazen on May 30, 2014, 10:08:26 amQuote from: howardpc on May 30, 2014, 09:47:14 amDo you also get a SIGSEGV with Code: [Select]begin   PageControl1.Pages[0].Free; end; ? Yes, this crash too (only in GTK2 while in Qt4 it works too). I tried to move the code from PageControlMouseUp to TabSheetMouseUp and it works (i.e. GTK2 is able to delete the last page w/o crash). I guess you need it because of some user-friendly GUI, right? Try this: Code: [Select]if (PageControl1.PageCount>1) or not (Sender is TPageControl) then     PageControl1.Pages[0].Free; as a general mouse up event, where user will have to close the last tab by click on the tab (not the header). You can open a issue, of course. ... I did one more test and it works for PageControlMouseDown. Yes, its specific GUI. I recompile with qt4 and original program is worked. Problem is solved. Thanks for idea. I will open an issue with gtk2.