Skip to content

Commit

Permalink
Osetrena vyjimka Connected property.
Browse files Browse the repository at this point in the history
Dotaz na TCPklient.connected muze vyvolat vyjimku pri nasilne prerusenem spojeni.
  • Loading branch information
horacekj committed Mar 16, 2017
1 parent 4c1c9a8 commit e2aa3d7
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 25 deletions.
7 changes: 1 addition & 6 deletions src/LokTokens.pas
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,10 @@ procedure TTokens.ResetMausTokens();

////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////

initialization
tokens := TTokens.Create();

finalization
FreeAndNil(tokens);

end.
4 changes: 0 additions & 4 deletions src/ModelovyCas.pas
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ procedure TModCas.Reset();

////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////

initialization
ModCas := TModCas.Create();

Expand Down
1 change: 1 addition & 0 deletions src/Sounds.pas
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,5 @@ initialization
SoundsPlay := TSoundsPlay.Create();
finalization
FreeAndNil(SoundsPlay);

end.//unit
36 changes: 28 additions & 8 deletions src/TCPClientPanel.pas
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,12 @@ constructor TPanelTCPClient.Create();

destructor TPanelTCPClient.Destroy();
begin
if (Self.tcpClient.Connected) then
Self.tcpClient.Disconnect();
try
if (Self.tcpClient.Connected) then
Self.tcpClient.Disconnect();
except

end;

// Znicime resuscitacni vlakno (vlakno obnovujici spojeni).
if (Assigned(Self.resusct)) then
Expand All @@ -352,11 +356,19 @@ destructor TPanelTCPClient.Destroy();
end;
end;

if (Assigned(Self.tcpClient)) then
FreeAndNil(Self.tcpClient);
try
if (Assigned(Self.tcpClient)) then
FreeAndNil(Self.tcpClient);
except

end;

if (Assigned(Self.parsed)) then
FreeAndNil(Self.parsed);
try
if (Assigned(Self.parsed)) then
FreeAndNil(Self.parsed);
except

end;

inherited Destroy();
end;//dtor
Expand Down Expand Up @@ -400,7 +412,11 @@ function TPanelTCPClient.Connect(host:string; port:Word):Integer;

function TPanelTCPClient.Disconnect():Integer;
begin
if (not Self.tcpClient.Connected) then Exit(1);
try
if (not Self.tcpClient.Connected) then Exit(1);
except

end;

Self.control_disconnect := true;
if Assigned(Self.rthread) then Self.rthread.Terminate;
Expand Down Expand Up @@ -999,7 +1015,11 @@ function TPanelTCPClient.StrToColor(str:string):TColor;

procedure TPanelTCPClient.SendLn(str:string);
begin
if (not Self.tcpClient.Connected) then Exit;
try
if (not Self.tcpClient.Connected) then Exit;
except

end;

try
Self.tcpClient.Socket.WriteLn(str);
Expand Down
4 changes: 2 additions & 2 deletions src/hJOPpanel.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
<VersionInfo Name="AutoIncBuild">True</VersionInfo>
<VersionInfo Name="MajorVer">1</VersionInfo>
<VersionInfo Name="MinorVer">4</VersionInfo>
<VersionInfo Name="Release">5</VersionInfo>
<VersionInfo Name="Release">6</VersionInfo>
<VersionInfo Name="Build">0</VersionInfo>
<VersionInfo Name="Debug">False</VersionInfo>
<VersionInfo Name="PreRelease">False</VersionInfo>
Expand All @@ -179,7 +179,7 @@
<VersionInfoKeys>
<VersionInfoKeys Name="CompanyName"/>
<VersionInfoKeys Name="FileDescription">Panel stanice hJOP</VersionInfoKeys>
<VersionInfoKeys Name="FileVersion">1.4.5.0</VersionInfoKeys>
<VersionInfoKeys Name="FileVersion">1.4.6.0</VersionInfoKeys>
<VersionInfoKeys Name="InternalName">hJOPpanel.exe</VersionInfoKeys>
<VersionInfoKeys Name="LegalCopyright">Jan Horáček</VersionInfoKeys>
<VersionInfoKeys Name="LegalTrademarks">Jan Horáček</VersionInfoKeys>
Expand Down
26 changes: 21 additions & 5 deletions src/uLIclient.pas
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,12 @@ constructor TBridgeClient.Create();

destructor TBridgeClient.Destroy();
begin
if (Self.tcpClient.Connected) then
Self.tcpClient.Disconnect();
try
if (Self.tcpClient.Connected) then
Self.tcpClient.Disconnect();
except

end;

Self.DestroyResusc();

Expand Down Expand Up @@ -189,7 +193,11 @@ function TBridgeClient.Connect(host:string; port:Word):Integer;

function TBridgeClient.Disconnect():Integer;
begin
if (not Self.tcpClient.Connected) then Exit(1);
try
if (not Self.tcpClient.Connected) then Exit(1);
except

end;

Self.control_disconnect := true;
if Assigned(Self.rthread) then Self.rthread.Terminate;
Expand Down Expand Up @@ -326,7 +334,11 @@ procedure TBridgeClient.Parse();

procedure TBridgeClient.SendLn(str:string);
begin
if (not Self.tcpClient.Connected) then Exit;
try
if (not Self.tcpClient.Connected) then Exit;
except

end;

try
Self.tcpClient.Socket.WriteLn(str);
Expand All @@ -339,7 +351,11 @@ procedure TBridgeClient.SendLn(str:string);

function TBridgeClient.GetOpened():boolean;
begin
Result := Self.tcpClient.Connected;
try
Result := Self.tcpClient.Connected;
except
Result := false;
end;
end;

////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit e2aa3d7

Please sign in to comment.