Gtk2: fixed crashes with gtk2 notebook when some of tabs is hidden (tabvisible=false).same as issue #20793.

git-svn-id: trunk@33959 -
This commit is contained in:
zeljko 2011-12-04 17:15:37 +00:00
parent 32c69a923e
commit ded3c818b7

View File

@ -470,6 +470,8 @@ class procedure TGtk2WSCustomTabControl.SetPageIndex(
const ATabControl: TCustomTabControl; const AIndex: integer);
var
GtkNotebook: PGtkNotebook;
ANewIndex: Integer;
Page: PGtkWidget;
begin
if not WSCheckHandleAllocated(ATabControl, 'SetPageIndex') then
Exit;
@ -477,8 +479,15 @@ begin
GtkNotebook := PGtkNoteBook(ATabControl.Handle);
if gtk_notebook_get_current_page(GtkNotebook) <> AIndex then
begin
gtk_object_set_data(PGtkObject(GtkNotebook), LCL_NotebookManualPageSwitchKey, ATabControl);
gtk_notebook_set_page(GtkNotebook, AIndex);
// gtk2 cannot set page if some tab in between tabvisible=false, so
// we must compare page handles.
if ATabControl.Page[AIndex].HandleAllocated then
begin
Page := PGtkWidget(ATabControl.Page[AIndex].Handle);
ANewIndex := gtk_notebook_page_num(GtkNoteBook, Page);
gtk_object_set_data(PGtkObject(GtkNotebook), LCL_NotebookManualPageSwitchKey, ATabControl);
gtk_notebook_set_page(GtkNotebook, ANewIndex);
end;
end;
UpdateNoteBookClientWidget(ATabControl);
end;