mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 11:17:57 +08:00
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:
@ -5816,6 +5816,7 @@ end;
|
||||
procedure TMainForm.CheckConnection;
|
||||
var
|
||||
connected: Boolean;
|
||||
choice: Integer;
|
||||
begin
|
||||
if not FMysqlConn.IsAlive then begin
|
||||
LogSQL('Connection failure detected. Trying to reconnect.', true);
|
||||
@ -5835,8 +5836,29 @@ begin
|
||||
except
|
||||
connected := False;
|
||||
end;
|
||||
if connected then FMysqlConn.Connection.Reconnect
|
||||
else FMysqlConn.Connection.Connect;
|
||||
while not FMysqlConn.IsAlive do begin
|
||||
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;
|
||||
TimerConnected.Enabled := true;
|
||||
LogSQL('Connected. Thread-ID: ' + IntToStr( MySQLConn.Connection.GetThreadId ));
|
||||
|
Reference in New Issue
Block a user