mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 21:56:00 +02:00
fixed mem leak
git-svn-id: trunk@6711 -
This commit is contained in:
parent
da84f603d8
commit
6d4be878cd
@ -6732,8 +6732,8 @@ end;
|
|||||||
Lines will be one memory block so that you can free the list and all lines
|
Lines will be one memory block so that you can free the list and all lines
|
||||||
with FreeMem(Lines).
|
with FreeMem(Lines).
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TGtkWidgetSet.WordWrap(DC: HDC; AText: PChar; MaxWidthInPixel: integer;
|
procedure TGtkWidgetSet.WordWrap(DC: HDC; AText: PChar;
|
||||||
var Lines: PPChar; var LineCount: integer);
|
MaxWidthInPixel: integer; var Lines: PPChar; var LineCount: integer);
|
||||||
var
|
var
|
||||||
{$IfDef GTK2}
|
{$IfDef GTK2}
|
||||||
UseFontDesc : PPangoFontDescription;
|
UseFontDesc : PPangoFontDescription;
|
||||||
@ -6891,6 +6891,7 @@ begin
|
|||||||
inc(i,2);
|
inc(i,2);
|
||||||
end;
|
end;
|
||||||
GetMem(Lines,TotalSize);
|
GetMem(Lines,TotalSize);
|
||||||
|
FillChar(Lines^,TotalSize,0);
|
||||||
|
|
||||||
// create Lines
|
// create Lines
|
||||||
CurLineEntry:=Lines;
|
CurLineEntry:=Lines;
|
||||||
@ -7015,6 +7016,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.621 2005/01/28 17:55:48 mattias
|
||||||
|
fixed mem leak
|
||||||
|
|
||||||
Revision 1.620 2005/01/22 22:26:16 mattias
|
Revision 1.620 2005/01/22 22:26:16 mattias
|
||||||
added sprite example
|
added sprite example
|
||||||
|
|
||||||
|
@ -2878,63 +2878,62 @@ begin
|
|||||||
TempDC := -1;
|
TempDC := -1;
|
||||||
TempPen := -1;
|
TempPen := -1;
|
||||||
TempBrush := -1;
|
TempBrush := -1;
|
||||||
|
try
|
||||||
|
Count := Min(StrLen(Str), Count);
|
||||||
|
|
||||||
Count := Min(StrLen(Str), Count);
|
GetTextMetrics(DC, TM);
|
||||||
|
|
||||||
GetTextMetrics(DC, TM);
|
DoCalcRect;
|
||||||
|
|
||||||
DoCalcRect;
|
If (Flags and DT_CalcRect) = DT_CalcRect then begin
|
||||||
|
CopyRect(Rect, theRect);
|
||||||
If (Flags and DT_CalcRect) = DT_CalcRect then begin
|
Result := 1;
|
||||||
CopyRect(Rect, theRect);
|
exit;
|
||||||
Result := 1;
|
end else begin
|
||||||
exit;
|
TempDC := SaveDC(DC);
|
||||||
end else begin
|
|
||||||
TempDC := SaveDC(DC);
|
|
||||||
end;
|
|
||||||
|
|
||||||
If (Flags and DT_NOCLIP) <> DT_NOCLIP then begin
|
|
||||||
If theRect.Right > Rect.Right then
|
|
||||||
theRect.Right := Rect.Right;
|
|
||||||
If theRect.Bottom > Rect.Bottom then
|
|
||||||
theRect.Bottom := Rect.Bottom;
|
|
||||||
IntersectClipRect(DC, theRect.Left, theRect.Top,
|
|
||||||
theRect.Right, theRect.Bottom);
|
|
||||||
end;
|
|
||||||
|
|
||||||
If (Flags and DT_SingleLine) = DT_SingleLine then begin
|
|
||||||
DrawLine(Str, Count, theRect.Top);
|
|
||||||
Result := 1;
|
|
||||||
end
|
|
||||||
else If (Lines <> nil) and (NumLines <> 0) then begin
|
|
||||||
For I := 0 to NumLines - 1 do begin
|
|
||||||
if I>0 then
|
|
||||||
Inc(theRect.Top, TM.tmDescent);// space between lines
|
|
||||||
|
|
||||||
If (((Flags and DT_EditControl) = DT_EditControl) and
|
|
||||||
(tm.tmHeight > (theRect.Bottom - theRect.Top))) or
|
|
||||||
(theRect.Top > theRect.Bottom)
|
|
||||||
then
|
|
||||||
break;
|
|
||||||
|
|
||||||
If Lines[I] <> nil then
|
|
||||||
DrawLine(Lines[I], StrLen(Lines[I]), theRect.Top);
|
|
||||||
|
|
||||||
Inc(theRect.Top, TM.tmHeight);
|
|
||||||
end;
|
end;
|
||||||
Result := 1;
|
|
||||||
|
If (Flags and DT_NOCLIP) <> DT_NOCLIP then begin
|
||||||
|
If theRect.Right > Rect.Right then
|
||||||
|
theRect.Right := Rect.Right;
|
||||||
|
If theRect.Bottom > Rect.Bottom then
|
||||||
|
theRect.Bottom := Rect.Bottom;
|
||||||
|
IntersectClipRect(DC, theRect.Left, theRect.Top,
|
||||||
|
theRect.Right, theRect.Bottom);
|
||||||
|
end;
|
||||||
|
|
||||||
|
If (Flags and DT_SingleLine) = DT_SingleLine then begin
|
||||||
|
DrawLine(Str, Count, theRect.Top);
|
||||||
|
Result := 1;
|
||||||
|
end
|
||||||
|
else If (Lines <> nil) and (NumLines <> 0) then begin
|
||||||
|
For I := 0 to NumLines - 1 do begin
|
||||||
|
if I>0 then
|
||||||
|
Inc(theRect.Top, TM.tmDescent);// space between lines
|
||||||
|
|
||||||
|
If (((Flags and DT_EditControl) = DT_EditControl) and
|
||||||
|
(tm.tmHeight > (theRect.Bottom - theRect.Top))) or
|
||||||
|
(theRect.Top > theRect.Bottom)
|
||||||
|
then
|
||||||
|
break;
|
||||||
|
|
||||||
|
If Lines[I] <> nil then
|
||||||
|
DrawLine(Lines[I], StrLen(Lines[I]), theRect.Top);
|
||||||
|
|
||||||
|
Inc(theRect.Top, TM.tmHeight);
|
||||||
|
end;
|
||||||
|
Result := 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
finally
|
||||||
|
Reallocmem(Lines, 0);
|
||||||
|
If TempBrush <> -1 then
|
||||||
|
SelectObject(DC, TempBrush);
|
||||||
|
If TempPen <> -1 then
|
||||||
|
DeleteObject(SelectObject(DC, TempPen));
|
||||||
|
If TempDC <> -1 then
|
||||||
|
RestoreDC(DC, TempDC);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Reallocmem(Lines, 0);
|
|
||||||
|
|
||||||
If TempBrush <> -1 then
|
|
||||||
SelectObject(DC, TempBrush);
|
|
||||||
|
|
||||||
If TempPen <> -1 then
|
|
||||||
DeleteObject(SelectObject(DC, TempPen));
|
|
||||||
|
|
||||||
If TempDC <> -1 then
|
|
||||||
RestoreDC(DC, TempDC);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Assert(False, Format('trace:> [TGtkWidgetSet.DrawText] DC:0x%x, Str:''%s'', Count: %d, Rect = %d,%d,%d,%d, Flags:%d',
|
Assert(False, Format('trace:> [TGtkWidgetSet.DrawText] DC:0x%x, Str:''%s'', Count: %d, Rect = %d,%d,%d,%d, Flags:%d',
|
||||||
@ -8863,6 +8862,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.390 2005/01/28 17:55:48 mattias
|
||||||
|
fixed mem leak
|
||||||
|
|
||||||
Revision 1.389 2005/01/27 19:03:51 mattias
|
Revision 1.389 2005/01/27 19:03:51 mattias
|
||||||
added QuestionDlg - a MessageDlg with custom buttons
|
added QuestionDlg - a MessageDlg with custom buttons
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user