From 6f99c2aab0aa648e6dea43c5349d8bcec93096e6 Mon Sep 17 00:00:00 2001 From: paul Date: Sat, 4 Apr 2009 09:55:53 +0000 Subject: [PATCH] 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 - --- lcl/include/interfacebase.inc | 8 ++++---- lcl/interfacebase.pp | 2 +- lcl/themes.pas | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lcl/include/interfacebase.inc b/lcl/include/interfacebase.inc index 8783ce070c..c1401792cd 100644 --- a/lcl/include/interfacebase.inc +++ b/lcl/include/interfacebase.inc @@ -13,7 +13,7 @@ * * * This file is part of the Lazarus Component Library (LCL) * * * - * See the file COPYING.modifiedLGPL.txt, included in this distribution, * + * See the file COPYING.modifiedLGPL.txt, included in this distribution, * * for details about the copyright. * * * * This program is distributed in the hope that it will be useful, * @@ -29,10 +29,10 @@ begin FThemeServices := CreateThemeServices; end; -destructor TWidgetSet.Destroy; +procedure TWidgetSet.BeforeDestruction; begin - FreeAndNil(FThemeServices); - inherited Destroy; + FreeAndNil(FThemeServices); // destroy before destructor to release resources + inherited BeforeDestruction; end; procedure TWidgetSet.PassCmdLineOptions; diff --git a/lcl/interfacebase.pp b/lcl/interfacebase.pp index b2b47222f8..eee2a1a49b 100644 --- a/lcl/interfacebase.pp +++ b/lcl/interfacebase.pp @@ -87,7 +87,7 @@ type function CreateThemeServices: TThemeServices; virtual; public constructor Create; virtual; - destructor Destroy; override; + procedure BeforeDestruction;override; procedure AppInit(var ScreenInfo: TScreenInfo); virtual; abstract; procedure AppRun(const ALoop: TApplicationMainLoop); virtual; diff --git a/lcl/themes.pas b/lcl/themes.pas index 6ec2a38fe1..ab3b72ec5c 100644 --- a/lcl/themes.pas +++ b/lcl/themes.pas @@ -472,6 +472,7 @@ type procedure PaintBorder(Control: TObject; EraseLRCorner: Boolean); virtual; procedure UpdateThemes; + property DottedBrush: HBRUSH read GetDottedBrush; property ThemesAvailable: Boolean read FThemesAvailable; property ThemesEnabled: Boolean read GetThemesEnabled; @@ -1875,7 +1876,7 @@ procedure TThemeServices.DrawElement(DC: HDC; Details: TThemedElementDetails; co begin OldColor1 := SetBkColor(DC, ColorToRGB(Color1)); OldColor2 := SetTextColor(DC, ColorToRGB(Color2)); - FillRect(DC, ARect, GetDottedBrush); + FillRect(DC, ARect, DottedBrush); SetBkColor(DC, OldColor1); SetTextColor(DC, OldColor2); end;