MG: fixed calling DestroyHandle if not HandleAllocated

git-svn-id: trunk@3352 -
This commit is contained in:
lazarus 2002-09-16 15:42:17 +00:00
parent 093d68ba1a
commit 37611d322b
2 changed files with 33 additions and 20 deletions

View File

@ -364,13 +364,14 @@ end;
procedure TBitmap.SetHandle(Value: HBITMAP); procedure TBitmap.SetHandle(Value: HBITMAP);
begin begin
if FImage.FHandle = Value then exit;
// TODO: the properties from new bitmap // TODO: the properties from new bitmap
with FImage do with FImage do begin
if FHandle <> Value then
begin
FreeContext; FreeContext;
Release; Release;
end;
FImage := TBitmapImage.Create; FImage := TBitmapImage.Create;
with FImage do begin
Reference; Reference;
FHandle:=Value; FHandle:=Value;
FillChar(FDIB, sizeof(FDIB), 0); FillChar(FDIB, sizeof(FDIB), 0);
@ -465,6 +466,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $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 Revision 1.19 2002/09/13 16:58:27 lazarus
MG: removed the 1x1 bitmap from TBitBtn MG: removed the 1x1 bitmap from TBitBtn

View File

@ -34,6 +34,7 @@ begin
// get the interface based item list // get the interface based item list
NewStrings:= TStrings(Pointer(CNSendMessage(LM_GETITEMS, Self, nil))); NewStrings:= TStrings(Pointer(CNSendMessage(LM_GETITEMS, Self, nil)));
// then delete internal list // then delete internal list
if FItems<>NewStrings then
FItems.Free; FItems.Free;
// and use the interface based list // and use the interface based list
FItems:= NewStrings; FItems:= NewStrings;
@ -50,7 +51,9 @@ end;
procedure TCustomComboBox.DestroyHandle; procedure TCustomComboBox.DestroyHandle;
var NewStrings : TStrings; var NewStrings : TStrings;
begin 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 // create an internal list for storing items internally
NewStrings:= TStringList.Create; NewStrings:= TStringList.Create;
// copy from interface based list // copy from interface based list
@ -62,7 +65,6 @@ begin
// and use the internal list // and use the internal list
FItems:= NewStrings; FItems:= NewStrings;
//writeln('TCustomComboBox.DestroyHandle B ',Name);
inherited DestroyHandle; inherited DestroyHandle;
end; end;
@ -85,7 +87,7 @@ begin
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Method: TCustomComboBox.DestroyHandle Method: TCustomComboBox.InitializeWnd
Params: --- Params: ---
Returns: Nothing Returns: Nothing
@ -455,9 +457,14 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
destructor TCustomComboBox.Destroy; destructor TCustomComboBox.Destroy;
begin begin
writeln('TCustomComboBox.Destroy A ',Name);
if HandleAllocated then DestroyHandle;
writeln('TCustomComboBox.Destroy B ',Name);
FItems.Free; FItems.Free;
FItems:=nil; FItems:=nil;
writeln('TCustomComboBox.Destroy C ',Name);
inherited Destroy; inherited Destroy;
writeln('TCustomComboBox.Destroy D ',Name,' ',FItems<>nil);
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -511,8 +518,7 @@ end;
function TCustomComboBox.GetItemIndex : integer; function TCustomComboBox.GetItemIndex : integer;
begin begin
if HandleAllocated then if HandleAllocated then
Result:= CNSendMessage(LM_GETITEMINDEX, Self, nil) FItemIndex:= CNSendMessage(LM_GETITEMINDEX, Self, nil);
else
Result:=FItemIndex; Result:=FItemIndex;
end; end;
@ -547,6 +553,9 @@ end;
{ {
$Log$ $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 Revision 1.12 2002/08/31 11:37:09 lazarus
MG: fixed destroying combobox MG: fixed destroying combobox