fixed some gtk2 intf mem leaks, clean ups

git-svn-id: trunk@6788 -
This commit is contained in:
mattias 2005-02-16 23:56:51 +00:00
parent ba5ffc3f0e
commit 81a07bf019
4 changed files with 95 additions and 66 deletions

View File

@ -1520,8 +1520,9 @@ begin
While FileList^ <> nil do While FileList^ <> nil do
begin begin
fileInfo := FileList^; fileInfo := FileList^;
CurFilename:=AnsiString(fileInfo); CurFilename:=fileInfo; // convert PChar to AnsiString (not typecast)
if (CurFilename<>'') and (Files.IndexOf(CurFilename)<0) then begin if (CurFilename<>'') and (Files.IndexOf(CurFilename)<0) then begin
CurFilename:=DirName+fileInfo;
Result:=CheckOpenedFilename(CurFilename); Result:=CheckOpenedFilename(CurFilename);
if not Result then exit; if not Result then exit;
Files.Add(CurFilename); Files.Add(CurFilename);
@ -1829,7 +1830,8 @@ begin
if (Data=nil) or (BEvent=nil) or (Column=0) or (Row=0) then ; if (Data=nil) or (BEvent=nil) or (Column=0) or (Row=0) then ;
theDialog:=TCommonDialog(GetLCLObject(Widget)); theDialog:=TCommonDialog(GetLCLObject(Widget));
if (theDialog is TOpenDialog) then begin if (theDialog is TOpenDialog) then begin
if (bevent <> nil) and (bevent^.thetype = GDK_2BUTTON_PRESS) and (PGtkFileSelection(theDialog.Handle)^.dir_list = widget) then begin if (bevent <> nil) and (gdk_event_get_type(bevent) = GDK_2BUTTON_PRESS)
and (PGtkFileSelection(theDialog.Handle)^.dir_list = widget) then begin
MenuWidget := gtk_object_get_data(PGtkObject(theDialog.Handle), 'LCLFilterMenu'); MenuWidget := gtk_object_get_data(PGtkObject(theDialog.Handle), 'LCLFilterMenu');
if MenuWidget <> nil then begin if MenuWidget <> nil then begin
AFilterEntry := gtk_object_get_data(PGtkObject(gtk_menu_get_active(PGtkMenu(MenuWidget))), 'LCLIsFilterMenuItem'); AFilterEntry := gtk_object_get_data(PGtkObject(gtk_menu_get_active(PGtkMenu(MenuWidget))), 'LCLIsFilterMenuItem');
@ -2977,6 +2979,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.265 2005/02/16 23:56:51 mattias
fixed some gtk2 intf mem leaks, clean ups
Revision 1.264 2005/02/16 23:31:16 mattias Revision 1.264 2005/02/16 23:31:16 mattias
fixed define templates quotes fixed define templates quotes

View File

@ -275,11 +275,12 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TGtkListStoreStringList.RemoveItemCallbacks(Index: integer); procedure TGtkListStoreStringList.RemoveItemCallbacks(Index: integer);
var //var
ListItem: TGtkTreeIter; // ListItem: TGtkTreeIter;
begin begin
UpdateItemCache; UpdateItemCache;
ListItem:=FCachedItems[Index]; debugln('TGtkListStoreStringList.RemoveItemCallbacks TODO');
//ListItem:=FCachedItems[Index];
{gtk_object_set_data(PGtkObject(ListItem),GtkListItemLCLListTag,nil); {gtk_object_set_data(PGtkObject(ListItem),GtkListItemLCLListTag,nil);
gtk_object_set_data(PGtkObject(ListItem),GtkListItemGtkListTag,nil);} gtk_object_set_data(PGtkObject(ListItem),GtkListItemGtkListTag,nil);}
end; end;
@ -310,20 +311,22 @@ begin
ReAllocMem(FCachedItems,SizeOf(TGtkTreeIter)*FCachedCount); ReAllocMem(FCachedItems,SizeOf(TGtkTreeIter)*FCachedCount);
if FGtkListStore<>nil then if FGtkListStore<>nil then
For I := 0 to FCachedCount - 1 do For I := 0 to FCachedCount - 1 do
gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(FGtkListStore), @FCachedItems[i], nil, I); gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(FGtkListStore),
@FCachedItems[i], nil, I);
Exclude(FStates,glsItemCacheNeedsUpdate); Exclude(FStates,glsItemCacheNeedsUpdate);
end; end;
procedure TGtkListStoreStringList.PutObject(Index: Integer; AnObject: TObject); procedure TGtkListStoreStringList.PutObject(Index: Integer; AnObject: TObject);
var //var
ListItem : TGtkTreeIter; // ListItem : TGtkTreeIter;
begin begin
if (Index < 0) or (Index >= Count) then if (Index < 0) or (Index >= Count) then
RaiseException('TGtkListStoreStringList.PutObject Out of bounds.') RaiseException('TGtkListStoreStringList.PutObject Out of bounds.')
else if FGtkListStore<>nil then begin else if FGtkListStore<>nil then begin
UpdateItemCache; UpdateItemCache;
ListItem:=FCachedItems[Index]; debugln('TGtkListStoreStringList.PutObject TODO');
{if ListItem <> nil then begin {ListItem:=FCachedItems[Index];
if ListItem <> nil then begin
gtk_object_set_data(PGtkObject(ListItem),'LCLStringsObject',AnObject); gtk_object_set_data(PGtkObject(ListItem),'LCLStringsObject',AnObject);
end;} end;}
end; end;
@ -599,6 +602,9 @@ end.
{ {
$Log$ $Log$
Revision 1.41 2005/02/16 23:56:51 mattias
fixed some gtk2 intf mem leaks, clean ups
Revision 1.40 2005/02/08 18:31:56 mattias Revision 1.40 2005/02/08 18:31:56 mattias
further completions for gtk2 listbox and listview further completions for gtk2 listbox and listview

View File

@ -202,15 +202,10 @@ function TGtk2WidgetSet.CreateComponent(Sender : TObject): THandle;
var var
Caption : ansistring; // the caption of "Sender" Caption : ansistring; // the caption of "Sender"
StrTemp : PChar; // same as "caption" but as PChar StrTemp : PChar; // same as "caption" but as PChar
TempWidget, TempWidget: PGtkWidget;
TempWidget2 : PGTKWidget; // pointer to gtk-widget (local use when neccessary) p: PGtkWidget; // ptr to the newly created GtkWidget
p : pointer; // ptr to the newly created GtkWidget
CompStyle, // componentstyle (type) of GtkWidget which will be created CompStyle, // componentstyle (type) of GtkWidget which will be created
TempInt : Integer; // local use when neccessary TempInt : Integer; // local use when neccessary
// - for csBitBtn
Box : Pointer; // currently only used for TCustomBitBtn
pixmapwid : pGtkWidget; // currently only used for TCustomBitBtn
label1 : pgtkwidget; // currently only used for TCustomBitBtn
SetupProps : boolean; SetupProps : boolean;
liststore : PGtkListStore; liststore : PGtkListStore;
renderer : PGtkCellRenderer; renderer : PGtkCellRenderer;
@ -289,7 +284,7 @@ begin
begin begin
P := gtk_scrolled_window_new(nil, nil); P := gtk_scrolled_window_new(nil, nil);
TempWidget := gtk_text_view_new(); TempWidget := gtk_text_view_new();
gtk_container_add(p, TempWidget); gtk_container_add(PGtkContainer(p), TempWidget);
GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(p)^.hscrollbar, GTK_CAN_FOCUS); GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(p)^.hscrollbar, GTK_CAN_FOCUS);
GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(p)^.vscrollbar, GTK_CAN_FOCUS); GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(p)^.vscrollbar, GTK_CAN_FOCUS);
@ -323,45 +318,45 @@ end;
function TGtk2WidgetSet.CreateListView(ListViewObject: TObject): PGtkWidget; function TGtk2WidgetSet.CreateListView(ListViewObject: TObject): PGtkWidget;
var var
GtkTreeView: PGtkWidget; GtkTreeView: PGtkWidget;
ListStore: PGtkListStore; ListStore: PGtkListStore;
nColumns: Integer; nColumns: Integer;
ListView: TCustomListView; ListView: TCustomListView;
GTypeArray: PGType; GTypeArray: PGType;
i: Integer; i: Integer;
renderer: PGtkCellRenderer; renderer: PGtkCellRenderer;
Column: PGtkTreeViewColumn; Column: PGtkTreeViewColumn;
procedure RefreshItems(const ListStore: PGtkListStore);
var
Iter: TGtkTreeIter;
Str: String;
ColCount: Integer;
i, x: Integer;
Item: TListItem;
begin
gtk_list_store_clear(ListStore);
for i := 0 to ListView.Items.Count-1 do begin
Item := ListView.Items.Item[i];
// Figure out how many columns are needed procedure RefreshItems(const ListStore: PGtkListStore);
if not(ListView.ViewStyle = vsReport) then begin var
gtk_list_store_append(ListStore, @Iter); Iter: TGtkTreeIter;
gtk_list_store_set(ListStore, @Iter,[1, PChar(Item.Caption),-1]); ColCount: Integer;
end i, x: Integer;
else begin Item: TListItem;
ColCount := ListView.Columns.Count; begin
if ColCount > (1 + Item.SubItems.Count) then gtk_list_store_clear(ListStore);
ColCount := 1 + Item.SubItems.Count; for i := 0 to ListView.Items.Count-1 do begin
if ColCount < 0 then ColCount := 1; Item := ListView.Items.Item[i];
gtk_list_store_append(ListStore, @Iter);
gtk_list_store_set(ListStore, @Iter,[1, PChar(Item.Caption),-1]);
for x := 1 to ColCount-1 do begin
gtk_list_store_set(ListStore, @Iter, [X+1, PChar(Item.SubItems.Strings[X-1]), -1]);
end;
end;
end;
end; // Figure out how many columns are needed
if not(ListView.ViewStyle = vsReport) then begin
gtk_list_store_append(ListStore, @Iter);
gtk_list_store_set(ListStore, @Iter,[1, PChar(Item.Caption),-1]);
end
else begin
ColCount := ListView.Columns.Count;
if ColCount > (1 + Item.SubItems.Count) then
ColCount := 1 + Item.SubItems.Count;
if ColCount < 0 then ColCount := 1;
gtk_list_store_append(ListStore, @Iter);
gtk_list_store_set(ListStore, @Iter,[1, PChar(Item.Caption),-1]);
for x := 1 to ColCount-1 do begin
gtk_list_store_set(ListStore, @Iter, [X+1, PChar(Item.SubItems.Strings[X-1]), -1]);
end;
end;
end;
end;
begin begin
Result := gtk_scrolled_window_new(nil, nil); Result := gtk_scrolled_window_new(nil, nil);
GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(Result)^.hscrollbar, GTK_CAN_FOCUS); GTK_WIDGET_UNSET_FLAGS(PGtkScrolledWindow(Result)^.hscrollbar, GTK_CAN_FOCUS);
@ -386,7 +381,7 @@ begin
for i := 1 to nColumns do begin for i := 1 to nColumns do begin
GTypeArray[i] := G_TYPE_STRING; GTypeArray[i] := G_TYPE_STRING;
end; end;
GTypeArray[nColumns+1] := -1; GTypeArray[nColumns+1] := 0; // -1;
ListStore := gtk_list_store_newv(nColumns, GTypeArray); ListStore := gtk_list_store_newv(nColumns, GTypeArray);
ReAllocMem(GTypeArray, 0); ReAllocMem(GTypeArray, 0);
@ -1504,6 +1499,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.24 2005/02/16 23:56:51 mattias
fixed some gtk2 intf mem leaks, clean ups
Revision 1.23 2005/02/08 18:31:56 mattias Revision 1.23 2005/02/08 18:31:56 mattias
further completions for gtk2 listbox and listview further completions for gtk2 listbox and listview

View File

@ -120,13 +120,13 @@ begin
Exit; Exit;
end; end;
if (FamilyName = '') or (AnsiCompareText(FamilyName,'*')=0) then begin if (FamilyName = '') or (CompareText(FamilyName,'*')=0) then begin
FamilyName := StrPas(lfFaceName); FamilyName := StrPas(lfFaceName);
if AnsiCompareText(FamilyName,'default')=0 then begin if CompareText(FamilyName,'default')=0 then begin
LoadDefaultFont; LoadDefaultFont;
exit; exit;
end; end;
FullString := AnsiString(FamilyName); FullString := FamilyName;
if IsFontNameXLogicalFontDesc(LongFontName) then if IsFontNameXLogicalFontDesc(LongFontName) then
if Abs(lfHeight)=0 then if Abs(lfHeight)=0 then
FullString := FullString + ' 12' FullString := FullString + ' 12'
@ -134,22 +134,39 @@ begin
FullString := FullString + ' ' + IntToStr(Abs(lfHeight)); FullString := FullString + ' ' + IntToStr(Abs(lfHeight));
end end
else begin else begin
FullString := AnsiString(FamilyName); FullString := FamilyName;
if IsFontNameXLogicalFontDesc(LongFontName) then if IsFontNameXLogicalFontDesc(LongFontName) then
if (PointSize = '') or (AnsiCompareText(PointSize,'*')=0) then if (PointSize = '') or (CompareText(PointSize,'*')=0) then
FullString := FullString + ' 12' FullString := FullString + ' 12'
else else
FullString := FullString + ' ' + IntToStr(StrToInt(PointSize) div 10); FullString := FullString + ' ' + IntToStr(StrToInt(PointSize) div 10);
end; end;
if FontNameRegistry='' then ;
if Foundry='' then ;
if WeightName='' then ;
if Slant='' then ;
if SetwidthName='' then ;
if AddStyleName='' then ;
if PixelSize='' then ;
if ResolutionX='' then ;
if ResolutionY='' then ;
if Spacing='' then ;
if AverageWidth='' then ;
if CharSetCoding='' then ;
if CharSetRegistry='' then ;
GdiObject^.GDIFontObject := pango_font_description_from_string(PChar(FullString)); GdiObject^.GDIFontObject :=
pango_font_description_from_string(PChar(FullString));
If lfWeight <> FW_DONTCARE then If lfWeight <> FW_DONTCARE then
pango_font_description_set_weight(GdiObject^.GDIFontObject, lfWeight); pango_font_description_set_weight(GdiObject^.GDIFontObject, lfWeight);
if lfItalic = 0 then if lfItalic = 0 then
pango_font_description_set_style(GdiObject^.GDIFontObject,PANGO_STYLE_NORMAL) pango_font_description_set_style(GdiObject^.GDIFontObject,
PANGO_STYLE_NORMAL)
else else
pango_font_description_set_style(GdiObject^.GDIFontObject,PANGO_STYLE_ITALIC); pango_font_description_set_style(GdiObject^.GDIFontObject,
PANGO_STYLE_ITALIC);
GdiObject^.StrikeOut := lfStrikeOut <> 0; GdiObject^.StrikeOut := lfStrikeOut <> 0;
GdiObject^.Underline := lfUnderline <> 0; GdiObject^.Underline := lfUnderline <> 0;
@ -450,14 +467,14 @@ begin
If (AttrList = nil) then If (AttrList = nil) then
AttrList := pango_attr_list_new(); AttrList := pango_attr_list_new();
If CurrentFont^.Underline then If Underline then
Attr := pango_attr_underline_new(PANGO_UNDERLINE_SINGLE) Attr := pango_attr_underline_new(PANGO_UNDERLINE_SINGLE)
else else
Attr := pango_attr_underline_new(PANGO_UNDERLINE_NONE); Attr := pango_attr_underline_new(PANGO_UNDERLINE_NONE);
pango_attr_list_change(AttrList,Attr); pango_attr_list_change(AttrList,Attr);
Attr := pango_attr_strikethrough_new(CurrentFont^.StrikeOut); Attr := pango_attr_strikethrough_new(StrikeOut);
pango_attr_list_change(AttrList,Attr); pango_attr_list_change(AttrList,Attr);
if (Options and ETO_CLIPPED) <> 0 then if (Options and ETO_CLIPPED) <> 0 then
@ -795,6 +812,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.13 2005/02/16 23:56:51 mattias
fixed some gtk2 intf mem leaks, clean ups
Revision 1.12 2005/01/23 11:43:38 mattias Revision 1.12 2005/01/23 11:43:38 mattias
fixed expandingtabs in synedit painting fixed expandingtabs in synedit painting