Skip to content

Commit

Permalink
SwtControl: If no element is attached, set state as "none"
Browse files Browse the repository at this point in the history
Avoids accidental crashes.
  • Loading branch information
PMeira committed Oct 11, 2023
1 parent 694f5dd commit 4345740
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Controls/SwtControl.pas
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ function GetState(Obj: TObj): Integer;
begin
with Obj do
begin
if ControlledElement = NIL then
begin
// If no element is attached, return CTRL_NONE to indicate we cannot tell the state
Result := ord(CTRL_NONE);
Exit;
end;
ControlledElement.ActiveTerminalIdx := ElementTerminal;
if ControlledElement.Closed[0] then
Result := ord(CTRL_CLOSE)
Expand Down

0 comments on commit 4345740

Please sign in to comment.