LCL-GTK3: Prevent a crash in Manjaro Linux. Issue , patch by Anton Kavalenka.

git-svn-id: trunk@65298 -
This commit is contained in:
juha 2021-06-23 18:19:15 +00:00
parent 4e0b593486
commit 4a7413fce7
3 changed files with 42 additions and 13 deletions

View File

@ -323,6 +323,7 @@ type
procedure register_transform_func(src_type: TGType; dest_type: TGType; transform_func: TGValueTransform); cdecl; inline; static;
function type_compatible(src_type: TGType; dest_type: TGType): gboolean; cdecl; inline; static;
function type_transformable(src_type: TGType; dest_type: TGType): gboolean; cdecl; inline; static;
procedure clear; inline;
end;
TGBoxedCopyFunc = function(boxed: gpointer): gpointer; cdecl;
TGBoxedFreeFunc = procedure(boxed: gpointer); cdecl;
@ -1966,6 +1967,11 @@ begin
Result := LazGObject2.g_value_type_transformable(src_type, dest_type);
end;
procedure TGValue.clear;
begin
fillchar(Self,sizeof(Self),0);
end;
function TGClosure.new_object(sizeof_closure: guint; object_: PGObject): PGClosure; cdecl;
begin
Result := LazGObject2.g_closure_new_object(sizeof_closure, object_);

View File

@ -674,16 +674,18 @@ begin
not (TCustomComboBox(TGtk3Widget(Data).LCLObject).Style.HasEditBox) and
not (TCustomComboBox(TGtk3Widget(Data).LCLObject).DroppedDown) then
begin
Value.g_type := G_TYPE_UINT;
Value.data[0].v_uint := 0;
Value.clear;
Value.init(G_TYPE_UINT);
Value.set_uint(0);
g_object_get_property(PgObject(cell),'ypad',@Value);
Value.data[0].v_int := 0;
g_object_set_property(PGObject(cell), 'ypad', @Value);
Value.unset;
end else
if wtListView in TGtk3Widget(Data).WidgetType then
begin
// DebugLn(['LCLIntfCellRenderer_CellDataFunc stamp=',iter^.stamp,' tree_model=',dbgs(tree_model),' cell=',dbgs(cell),' WidgetInfo=',WidgetInfo <> nil,' Time=',TimeToStr(Now)]);
Value.g_type := G_TYPE_STRING;
//Value.g_type := G_TYPE_STRING;
gtk_tree_model_get(tree_model, iter, [0, @ListItem, -1]);
if (ListItem = nil) and TCustomListView(TGtk3Widget(Data).LCLObject).OwnerData then
ListItem := TCustomListView(TGtk3Widget(Data).LCLObject).Items[LCLCellRenderer^.Index];
@ -705,24 +707,32 @@ begin
if ListColumn.Index-1 <= ListItem.SubItems.Count-1 then
S := ListItem.SubItems.Strings[LCLCellRenderer^.ColumnIndex-1];
Value.data[0].v_pointer := PgChar(S);
Value.clear;
Value.init(G_TYPE_STRING);
Value.set_string(PgChar(S));
cell^.set_property('text', @Value);
Value.unset;
end else
if (wtListBox in TGtk3Widget(Data).WidgetType) then
begin
if TGtk3ListBox(Data).ListBoxStyle < lbOwnerDrawFixed then
begin
Value.g_type := G_TYPE_STRING;
Value.data[0].v_pointer := nil;
value.clear;
value.init(G_TYPE_STRING);
value.set_string(nil);
cell^.get_property('text', @Value);
value.unset;
// DebugLn('PropertyType=',dbgs(Value.g_type),' IsString=',dbgs(Value.g_type = G_TYPE_STRING),' getString=',Value.get_string);
S := TCustomListBox(TGtk3Widget(Data).LCLObject).Items.Strings[LCLCellRenderer^.Index];
// DebugLn('LCLCellRenderer^.Index=',dbgs(LCLCellRenderer^.Index),' text=',Str);
Value.data[0].v_pointer := PgChar(S);
// Value.set_string(Str);
//Value.data[0].v_pointer := PgChar(S);
value.clear;
value.init(G_TYPE_STRING);
Value.set_string(PgChar(S));
// set text only if we are not ownerdrawn !
cell^.set_property('text', @Value);
Value.unset;
// DebugLn('IsFixedCellSize ',dbgs(PGtkTreeView(TGtk3Widget(Data).GetContainerWidget)^.get_fixed_height_mode));
end else
begin

View File

@ -3043,8 +3043,13 @@ var
wtype:TGType;
begin
fWidget^.get_allocation(@Alloc);
APoint.X:=alloc.X;
APoint.Y:=alloc.Y;
if (alloc.X=-1) and (alloc.Y=-1) and (alloc.height=1) and (alloc.width=1) then
// default allocation
else
begin
APoint.X:=alloc.X;
APoint.Y:=alloc.Y;
end;
prnt:=self.GetParent; // TGtk3Widget
if (prnt<>nil) then
@ -6391,7 +6396,11 @@ begin
if IsTreeView then
begin
Path := gtk_tree_path_new_from_indices(AIndex, [-1]);
PGtkTreeView(GetContainerWidget)^.get_cell_area(Path, nil, @ItemRect);
if GetContainerWidget^.get_realized then
begin
PGtkTreeView(GetContainerWidget)^.get_cell_area(Path, nil, @ItemRect);
// here may be optimization
end;
gtk_tree_path_free(Path);
end else
begin
@ -6414,7 +6423,11 @@ begin
if IsTreeView then
begin
Path := gtk_tree_path_new_from_indices(AIndex, [-1]);
PGtkTreeView(GetContainerWidget)^.get_cell_area(Path, nil, @ItemRect);
if GetContainerWidget^.get_realized then
begin
PGtkTreeView(GetContainerWidget)^.get_cell_area(Path, nil, @ItemRect);
// here may be optimization
end;
gtk_tree_path_free(Path);
end else
begin