Recent

Author Topic: SIGSERV while closing last TTabSheet on TPageControl  (Read 6649 times)

yuray

  • Newbie
  • Posts: 4
SIGSERV while closing last TTabSheet on TPageControl
« on: May 28, 2014, 01:41:45 pm »
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

  • Hero Member
  • *****
  • Posts: 5563
    • Bart en Mariska's Webstek
Re: SIGSERV while closing last TTabSheet on TPageControl
« Reply #1 on: May 28, 2014, 03:34:26 pm »
Code: [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

  • Newbie
  • Posts: 4
Re: SIGSERV while closing last TTabSheet on TPageControl
« Reply #2 on: May 29, 2014, 07:06:06 am »
Code: [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

  • Hero Member
  • *****
  • Posts: 5563
    • Bart en Mariska's Webstek
Re: SIGSERV while closing last TTabSheet on TPageControl
« Reply #3 on: May 29, 2014, 03:43:46 pm »
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

  • Newbie
  • Posts: 4
Re: SIGSERV while closing last TTabSheet on TPageControl
« Reply #4 on: May 30, 2014, 09:20:10 am »
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

  • Hero Member
  • *****
  • Posts: 4144
Re: SIGSERV while closing last TTabSheet on TPageControl
« Reply #5 on: May 30, 2014, 09:47:14 am »
Do you also get a SIGSEGV with
Code: [Select]
begin
  PageControl1.Pages[0].Free;
end;
?

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: SIGSERV while closing last TTabSheet on TPageControl
« Reply #6 on: May 30, 2014, 10:08:26 am »
Do 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.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: SIGSERV while closing last TTabSheet on TPageControl
« Reply #7 on: May 30, 2014, 10:21:12 am »
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?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: SIGSERV while closing last TTabSheet on TPageControl
« Reply #8 on: May 30, 2014, 10:36:24 am »
Quote
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?

Yes, it does (it must be set in Options and it must also be done in OnCloseTabClicked: Sender.Free;).
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

yuray

  • Newbie
  • Posts: 4
Re: SIGSERV while closing last TTabSheet on TPageControl
« Reply #9 on: June 02, 2014, 09:10:53 am »
Do 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.

 

TinyPortal © 2005-2018