lcl: destroy ThemeServices in the TWidgetset.BeforeDestruction method since it can release some gdi objects and some widgetsets (like gtk) stores gdi objects in internal structures and release them in the widgetset destructor

git-svn-id: trunk@19212 -
This commit is contained in:
paul 2009-04-04 09:55:53 +00:00
parent 91dea6fbf8
commit 6f99c2aab0
3 changed files with 7 additions and 6 deletions

View File

@ -29,10 +29,10 @@ begin
FThemeServices := CreateThemeServices; FThemeServices := CreateThemeServices;
end; end;
destructor TWidgetSet.Destroy; procedure TWidgetSet.BeforeDestruction;
begin begin
FreeAndNil(FThemeServices); FreeAndNil(FThemeServices); // destroy before destructor to release resources
inherited Destroy; inherited BeforeDestruction;
end; end;
procedure TWidgetSet.PassCmdLineOptions; procedure TWidgetSet.PassCmdLineOptions;

View File

@ -87,7 +87,7 @@ type
function CreateThemeServices: TThemeServices; virtual; function CreateThemeServices: TThemeServices; virtual;
public public
constructor Create; virtual; constructor Create; virtual;
destructor Destroy; override; procedure BeforeDestruction;override;
procedure AppInit(var ScreenInfo: TScreenInfo); virtual; abstract; procedure AppInit(var ScreenInfo: TScreenInfo); virtual; abstract;
procedure AppRun(const ALoop: TApplicationMainLoop); virtual; procedure AppRun(const ALoop: TApplicationMainLoop); virtual;

View File

@ -472,6 +472,7 @@ type
procedure PaintBorder(Control: TObject; EraseLRCorner: Boolean); virtual; procedure PaintBorder(Control: TObject; EraseLRCorner: Boolean); virtual;
procedure UpdateThemes; procedure UpdateThemes;
property DottedBrush: HBRUSH read GetDottedBrush;
property ThemesAvailable: Boolean read FThemesAvailable; property ThemesAvailable: Boolean read FThemesAvailable;
property ThemesEnabled: Boolean read GetThemesEnabled; property ThemesEnabled: Boolean read GetThemesEnabled;
@ -1875,7 +1876,7 @@ procedure TThemeServices.DrawElement(DC: HDC; Details: TThemedElementDetails; co
begin begin
OldColor1 := SetBkColor(DC, ColorToRGB(Color1)); OldColor1 := SetBkColor(DC, ColorToRGB(Color1));
OldColor2 := SetTextColor(DC, ColorToRGB(Color2)); OldColor2 := SetTextColor(DC, ColorToRGB(Color2));
FillRect(DC, ARect, GetDottedBrush); FillRect(DC, ARect, DottedBrush);
SetBkColor(DC, OldColor1); SetBkColor(DC, OldColor1);
SetTextColor(DC, OldColor2); SetTextColor(DC, OldColor2);
end; end;