From b63122a94e6adb1fb7f291bc483bf397edd84691 Mon Sep 17 00:00:00 2001 From: pierre Date: Wed, 27 Mar 2002 11:22:24 +0000 Subject: [PATCH] * fix problems for updating Debuggee title if Ctrl-C pressed --- ide/windebug.pas | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/ide/windebug.pas b/ide/windebug.pas index 0a3a825b76..120b43284b 100644 --- a/ide/windebug.pas +++ b/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);