mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-07 11:36:18 +02:00
Qt: fixed few memleaks in Qt library with our handling of QRegion. Each reference created by QPainter_clipRegion() must be destroyed.Small optimization in TQtWidgetSet.IntersectClipRect.
git-svn-id: trunk@31622 -
This commit is contained in:
parent
de79ddfe3f
commit
da5f9a5670
@ -2977,9 +2977,14 @@ begin
|
|||||||
{$ifdef VerboseQt}
|
{$ifdef VerboseQt}
|
||||||
Write('TQtDeviceContext.region() ');
|
Write('TQtDeviceContext.region() ');
|
||||||
{$endif}
|
{$endif}
|
||||||
if vRegion.Widget=nil then
|
if vRegion.Widget <> nil then
|
||||||
|
begin
|
||||||
|
QRegion_destroy(vRegion.Widget);
|
||||||
|
vRegion.Widget := nil;
|
||||||
|
end;
|
||||||
|
if vRegion.Widget = nil then
|
||||||
vRegion.Widget := QRegion_Create();
|
vRegion.Widget := QRegion_Create();
|
||||||
|
|
||||||
QPainter_clipRegion(Widget, vRegion.Widget);
|
QPainter_clipRegion(Widget, vRegion.Widget);
|
||||||
Result := vRegion;
|
Result := vRegion;
|
||||||
end;
|
end;
|
||||||
|
@ -2489,7 +2489,7 @@ end;
|
|||||||
function TQtWidgetSet.GetClipRGN(DC : hDC; RGN : hRGN): Longint;
|
function TQtWidgetSet.GetClipRGN(DC : hDC; RGN : hRGN): Longint;
|
||||||
begin
|
begin
|
||||||
{$ifdef VerboseQtWinAPI}
|
{$ifdef VerboseQtWinAPI}
|
||||||
Write('Trace: [WinAPI GetClipRgn]',
|
Writeln('Trace: [WinAPI GetClipRgn]',
|
||||||
' DC: ', dbghex(DC),
|
' DC: ', dbghex(DC),
|
||||||
' RGN: ', dbghex(Rgn));
|
' RGN: ', dbghex(Rgn));
|
||||||
if RGN<>0 then
|
if RGN<>0 then
|
||||||
@ -2501,13 +2501,21 @@ begin
|
|||||||
Result := -1;
|
Result := -1;
|
||||||
if not IsValidDC(DC) then
|
if not IsValidDC(DC) then
|
||||||
exit;
|
exit;
|
||||||
if rgn=0 then
|
if Rgn = 0 then
|
||||||
exit;
|
exit;
|
||||||
if not TQtDeviceContext(DC).getClipping then
|
if not TQtDeviceContext(DC).getClipping then
|
||||||
Result := 0
|
Result := 0
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
QPainter_ClipRegion(TQtDeviceContext(DC).Widget, TQtRegion(Rgn).Widget);
|
// if our TQtRegion contains widget then
|
||||||
|
// first destroy it because QPainter creates
|
||||||
|
// new reference.
|
||||||
|
if TQtRegion(Rgn).Widget <> nil then
|
||||||
|
begin
|
||||||
|
QRegion_destroy(TQtRegion(Rgn).Widget);
|
||||||
|
TQtRegion(Rgn).Widget := QRegion_create;
|
||||||
|
end;
|
||||||
|
QPainter_clipRegion(TQtDeviceContext(DC).Widget, TQtRegion(Rgn).Widget);
|
||||||
Result := 1;
|
Result := 1;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -4419,26 +4427,33 @@ begin
|
|||||||
if not IsValidDC(DC) then exit;
|
if not IsValidDC(DC) then exit;
|
||||||
|
|
||||||
IntersectRgn := QRegion_create(Left, Top, Right - Left, Bottom - Top);
|
IntersectRgn := QRegion_create(Left, Top, Right - Left, Bottom - Top);
|
||||||
Rgn := QRegion_create;
|
|
||||||
try
|
try
|
||||||
if QtDC.getClipping then
|
if QtDC.getClipping then
|
||||||
begin
|
begin
|
||||||
QPainter_clipRegion(QtDC.Widget, Rgn);
|
Rgn := QRegion_create;
|
||||||
if QRegion_isEmpty(Rgn) then
|
try
|
||||||
QtDC.setClipRegion(IntersectRgn)
|
QPainter_clipRegion(QtDC.Widget, Rgn);
|
||||||
else
|
if QRegion_isEmpty(Rgn) then
|
||||||
QtDC.setClipRegion(IntersectRgn, QtIntersectClip);
|
QtDC.setClipRegion(IntersectRgn)
|
||||||
end
|
else
|
||||||
else
|
QtDC.setClipRegion(IntersectRgn, QtIntersectClip);
|
||||||
|
QtDC.setClipping(True);
|
||||||
|
// recreate Rgn
|
||||||
|
QRegion_destroy(Rgn);
|
||||||
|
Rgn := QRegion_create;
|
||||||
|
QPainter_clipRegion(QtDC.Widget, Rgn);
|
||||||
|
Result := QtDC.GetRegionType(Rgn);
|
||||||
|
finally
|
||||||
|
QRegion_destroy(Rgn);
|
||||||
|
end;
|
||||||
|
end else
|
||||||
begin
|
begin
|
||||||
QtDC.setClipRegion(InterSectRgn);
|
QtDC.setClipRegion(InterSectRgn);
|
||||||
QPainter_clipRegion(QtDC.Widget, Rgn);
|
QtDC.setClipping(True);
|
||||||
|
Result := QtDC.GetRegionType(InterSectRgn);
|
||||||
end;
|
end;
|
||||||
QtDC.setClipping(True);
|
|
||||||
Result := QtDC.GetRegionType(Rgn);
|
|
||||||
finally
|
finally
|
||||||
QRegion_destroy(IntersectRgn);
|
QRegion_destroy(IntersectRgn);
|
||||||
QRegion_destroy(Rgn);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user