Background: An optimal fix would be to programmatically disallow the GUI thread (fx inside event handlers) access to anything that happens over the network (fx executing queries on the database connection objects). There's a lot of that stuff going on in HeidiSQL as is however, so fixing things right is a lot of work. Therefore, this is a quick interim fix.

Bugfix: When the connection fails, prevent paint and present a modal dialog until the situation is resolved.
This commit is contained in:
rosenfield.albert
2009-03-04 18:59:25 +00:00
parent 21134ac51e
commit 614b8c4851

View File

@ -5816,6 +5816,7 @@ end;
procedure TMainForm.CheckConnection; procedure TMainForm.CheckConnection;
var var
connected: Boolean; connected: Boolean;
choice: Integer;
begin begin
if not FMysqlConn.IsAlive then begin if not FMysqlConn.IsAlive then begin
LogSQL('Connection failure detected. Trying to reconnect.', true); LogSQL('Connection failure detected. Trying to reconnect.', true);
@ -5835,8 +5836,29 @@ begin
except except
connected := False; connected := False;
end; end;
if connected then FMysqlConn.Connection.Reconnect while not FMysqlConn.IsAlive do begin
else FMysqlConn.Connection.Connect; try
if connected then FMysqlConn.Connection.Reconnect
else FMysqlConn.Connection.Connect;
except
on E: Exception do begin
MainForm.Visible := False;
choice := MessageDlg(
'Connection to the server has been lost.'#10#10 +
E.Message + #10#10 +
'Click Abort to exit this session.',
mtError,
[mbRetry, mbAbort], 0
);
if choice = mrAbort then begin
Close;
Halt(1);
end;
end;
end;
if FMysqlConn.IsAlive then MainForm.Visible := True;
end;
time_connected := 0; time_connected := 0;
TimerConnected.Enabled := true; TimerConnected.Enabled := true;
LogSQL('Connected. Thread-ID: ' + IntToStr( MySQLConn.Connection.GetThreadId )); LogSQL('Connected. Thread-ID: ' + IntToStr( MySQLConn.Connection.GetThreadId ));