Browse Source

* fix problems for updating Debuggee title if Ctrl-C pressed

pierre 23 years ago
parent
commit
b63122a94e
1 changed files with 24 additions and 4 deletions
  1. 24 4
      ide/windebug.pas

+ 24 - 4
ide/windebug.pas

@@ -23,6 +23,9 @@ interface
   procedure  ChangeDebuggeeWindowTitleTo(State : DebuggeeState);
 
   function CygDrivePrefix : string;
+const
+
+  main_pid_valid : boolean = false;
 
 implementation
 
@@ -88,20 +91,34 @@ begin
     RegCloseKey(Key);
 end;
 
+const
+  MaxTitleLength = 512;
+  main_pid : longint = 0;
+
+
 function GetWindowHandle(H : HWND; state : LPARAM) : WINBOOL;stdcall;
    var pTitle, pEnd, pNewTitle : pchar;
        len : longint;
    begin
      GetWindowHandle:=true;
-     GetMem(pTitle,256);
+     GetMem(pTitle,MaxTitleLength);
      { we want all windows !! }
-     if GetWindowThreadProcessId(H,nil)=inferior_pid then
+     if (GetWindowThreadProcessId(H,nil)=inferior_pid) or
+     main_pid_valid and (GetWindowThreadProcessId(H,nil)=main_pid) then
        begin
-         len:=GetWindowText(H,pTitle,256);
+         if not main_pid_valid then
+           begin
+             main_pid:=inferior_pid;
+             main_pid_valid:=true;
+           end;
+         len:=GetWindowText(H,pTitle,MaxTitleLength);
          if DebuggeeState(State) = Stopped_State then
            begin
              GetMem(pNewTitle,len+50);
              pEnd:=strpos(pTitle,'... running under FP debugger');
+             if assigned(pEnd) then
+               pEnd^:=#0;
+             pEnd:=strpos(pTitle,'... stopped by FP debugger');
              if assigned(pEnd) then
                pEnd^:=#0;
              strcopy(pNewTitle,pTitle);
@@ -113,6 +130,9 @@ function GetWindowHandle(H : HWND; state : LPARAM) : WINBOOL;stdcall;
            begin
              GetMem(pNewTitle,len+50);
              pEnd:=strpos(pTitle,'... stopped by FP debugger');
+             if assigned(pEnd) then
+               pEnd^:=#0;
+             pEnd:=strpos(pTitle,'... running under FP debugger');
              if assigned(pEnd) then
                pEnd^:=#0;
              strcopy(pNewTitle,pTitle);
@@ -121,7 +141,7 @@ function GetWindowHandle(H : HWND; state : LPARAM) : WINBOOL;stdcall;
              FreeMem(pNewTitle,len+50);
            end;
        end;
-     FreeMem(pTitle,256);
+     FreeMem(pTitle,MaxTitleLength);
    end;
 
  procedure  ChangeDebuggeeWindowTitleTo(State : DebuggeeState);