Jump to content


Photo

Handle leaks


  • Please log in to reply
1 reply to this topic

#1 AIM

AIM

    Senior Member

  • Honorable Members
  • PipPip
  • 202 posts

Posted 22 November 2010 - 02:16 PM

Boki,

At the moment I run intensive memory tests here and found two handle leaks in your code.

1. "procedure TNxCustomGridControl.RedrawBorder" seems to have a handle leak.

The following code fixes this leak:

CODE
procedure TNxCustomGridControl.RedrawBorder;
......
    
      DrawThemeBackground(Theme, DC, 1, 0, R, @R);
      ReleaseDC(Handle, DC);
      CloseThemeData(Theme); // <------------ added
    end else BorderWidth := 0;
end;



2. Another thing I have observed is that "procedure TNxCustomGridControl.CreateWnd;" is called twice in certain TForms here. I could fix this leak by changing this method as follows:

CODE
procedure TNxCustomGridControl.CreateWnd;
begin
  inherited;
  if IsThemed then
  begin
    if FTheme = 0 then  // <------------ added
    begin // <------------ added
      FTheme := OpenThemeData(Handle, teHeader);
      FDefaultStyleDisplay.Theme := FTheme;
    end; // <------------ added
  end;
end;



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 22 November 2010 - 08:03 PM

Hello AIM,

I have fixed it. Thank you.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users