From 37611d322b3d81c7637db71aa55a12a4244ba8fb Mon Sep 17 00:00:00 2001 From: lazarus Date: Mon, 16 Sep 2002 15:42:17 +0000 Subject: [PATCH] MG: fixed calling DestroyHandle if not HandleAllocated git-svn-id: trunk@3352 - --- lcl/include/bitmap.inc | 30 +++++++++++++++++------------- lcl/include/customcombobox.inc | 23 ++++++++++++++++------- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/lcl/include/bitmap.inc b/lcl/include/bitmap.inc index 396ea4256f..6c3098daad 100644 --- a/lcl/include/bitmap.inc +++ b/lcl/include/bitmap.inc @@ -364,20 +364,21 @@ end; procedure TBitmap.SetHandle(Value: HBITMAP); begin + if FImage.FHandle = Value then exit; // TODO: the properties from new bitmap - with FImage do - if FHandle <> Value then - begin - FreeContext; - Release; - FImage := TBitmapImage.Create; - Reference; - FHandle:=Value; - FillChar(FDIB, sizeof(FDIB), 0); - if Value <> 0 then - GetObject(FHandle, SizeOf(FDIB), @FDIB); - Changed(Self); - end; + with FImage do begin + FreeContext; + Release; + end; + FImage := TBitmapImage.Create; + with FImage do begin + Reference; + FHandle:=Value; + FillChar(FDIB, sizeof(FDIB), 0); + if Value <> 0 then + GetObject(FHandle, SizeOf(FDIB), @FDIB); + Changed(Self); + end; end; procedure TBitmap.SetMaskHandle(Value: HBITMAP); @@ -465,6 +466,9 @@ end; { ============================================================================= $Log$ + Revision 1.20 2002/09/16 15:42:17 lazarus + MG: fixed calling DestroyHandle if not HandleAllocated + Revision 1.19 2002/09/13 16:58:27 lazarus MG: removed the 1x1 bitmap from TBitBtn diff --git a/lcl/include/customcombobox.inc b/lcl/include/customcombobox.inc index 2dc2510b6a..add6776fc7 100644 --- a/lcl/include/customcombobox.inc +++ b/lcl/include/customcombobox.inc @@ -34,7 +34,8 @@ begin // get the interface based item list NewStrings:= TStrings(Pointer(CNSendMessage(LM_GETITEMS, Self, nil))); // then delete internal list - FItems.Free; + if FItems<>NewStrings then + FItems.Free; // and use the interface based list FItems:= NewStrings; end; @@ -50,7 +51,9 @@ end; procedure TCustomComboBox.DestroyHandle; var NewStrings : TStrings; begin - //writeln('TCustomComboBox.DestroyHandle ',Name); + if not HandleAllocated then begin + if (length(Name) div (length(Name) div 10000))=0 then ; + end; // create an internal list for storing items internally NewStrings:= TStringList.Create; // copy from interface based list @@ -62,7 +65,6 @@ begin // and use the internal list FItems:= NewStrings; - //writeln('TCustomComboBox.DestroyHandle B ',Name); inherited DestroyHandle; end; @@ -85,7 +87,7 @@ begin end; {------------------------------------------------------------------------------ - Method: TCustomComboBox.DestroyHandle + Method: TCustomComboBox.InitializeWnd Params: --- Returns: Nothing @@ -455,9 +457,14 @@ end; ------------------------------------------------------------------------------} destructor TCustomComboBox.Destroy; begin + writeln('TCustomComboBox.Destroy A ',Name); + if HandleAllocated then DestroyHandle; + writeln('TCustomComboBox.Destroy B ',Name); FItems.Free; FItems:=nil; + writeln('TCustomComboBox.Destroy C ',Name); inherited Destroy; + writeln('TCustomComboBox.Destroy D ',Name,' ',FItems<>nil); end; {------------------------------------------------------------------------------ @@ -511,9 +518,8 @@ end; function TCustomComboBox.GetItemIndex : integer; begin if HandleAllocated then - Result:= CNSendMessage(LM_GETITEMINDEX, Self, nil) - else - Result:=FItemIndex; + FItemIndex:= CNSendMessage(LM_GETITEMINDEX, Self, nil); + Result:=FItemIndex; end; {------------------------------------------------------------------------------ @@ -547,6 +553,9 @@ end; { $Log$ + Revision 1.13 2002/09/16 15:42:17 lazarus + MG: fixed calling DestroyHandle if not HandleAllocated + Revision 1.12 2002/08/31 11:37:09 lazarus MG: fixed destroying combobox