Browse Source

* Fix Access Violation when starting debug server failed

Michaël Van Canneyt 1 year ago
parent
commit
26e66fda75
1 changed files with 19 additions and 17 deletions
  1. 19 17
      packages/fcl-process/src/dbugintf.pp

+ 19 - 17
packages/fcl-process/src/dbugintf.pp

@@ -118,6 +118,8 @@ var
 Procedure WriteMessage(Const Msg : TDebugMessage);
 
 begin
+  if not Assigned(MsgBuffer) then
+    exit;
   MsgBuffer.Seek(0,soFrombeginning);
   WriteDebugMessageToStream(MsgBuffer,Msg);
   DebugClient.SendMessage(mtUnknown,MsgBuffer);
@@ -343,25 +345,25 @@ begin
   AlwaysDisplayPID:= ShowPID;
   DebugClient:=TSimpleIPCClient.Create(Nil);
   DebugClient.ServerID:=DebugServerID;
-  If not DebugClient.ServerRunning then
-    begin
-    ServerID:=StartDebugServer(ADebugServerExe,ARaiseExceptionOnSendError,ServerLogFileName);
-    if ServerID = 0 then
-      begin
-      DebugDisabled := True;
-      FreeAndNil(DebugClient);
-      Exit;
-      end
-    else
-      DebugDisabled := False;
-    I:=0;
-    While (I<100) and not DebugClient.ServerRunning do
+  try
+    If not DebugClient.ServerRunning then
       begin
-      Inc(I);
-      Sleep(100);
+      ServerID:=StartDebugServer(ADebugServerExe,ARaiseExceptionOnSendError,ServerLogFileName);
+      if ServerID = 0 then
+        begin
+        DebugDisabled := True;
+        FreeAndNil(DebugClient);
+        Exit;
+        end
+      else
+        DebugDisabled := False;
+      I:=0;
+      While (I<100) and not DebugClient.ServerRunning do
+        begin
+        Inc(I);
+        Sleep(100);
+        end;
       end;
-    end;
-  try
     DebugClient.Connect;
   except
     FreeAndNil(DebugClient);