mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-14 00:59:38 +02:00
freeing stopped external tools
git-svn-id: trunk@2859 -
This commit is contained in:
parent
049d1ac44b
commit
6b2a4d1f10
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -76,6 +76,7 @@ debugger/gdbdebugger.pp svneol=native#text/pascal
|
||||
debugger/gdbmidebugger.pp svneol=native#text/pascal
|
||||
debugger/localsdlg.lrs svneol=native#text/pascal
|
||||
debugger/localsdlg.pp svneol=native#text/pascal
|
||||
debugger/processlist.pas svneol=native#text/pascal
|
||||
debugger/tbreakpointsdlg.lfm svneol=native#text/plain
|
||||
debugger/tcallstackdlg.lfm svneol=native#text/plain
|
||||
debugger/tdbgoutputform.lfm svneol=native#text/plain
|
||||
@ -157,6 +158,7 @@ ide/aboutfrm.lrs svneol=native#text/pascal
|
||||
ide/aboutfrm.pas svneol=native#text/pascal
|
||||
ide/basedebugmanager.pas svneol=native#text/pascal
|
||||
ide/buildlazdialog.pas svneol=native#text/pascal
|
||||
ide/clipboardhistory.pas svneol=native#text/pascal
|
||||
ide/codeexplorer.lfm svneol=native#text/plain
|
||||
ide/codeexplorer.lrs svneol=native#text/pascal
|
||||
ide/codeexplorer.pas svneol=native#text/pascal
|
||||
|
133
debugger/processlist.pas
Normal file
133
debugger/processlist.pas
Normal file
@ -0,0 +1,133 @@
|
||||
{
|
||||
***************************************************************************
|
||||
* *
|
||||
* This source is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This code is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* General Public License for more details. *
|
||||
* *
|
||||
* A copy of the GNU General Public License is available on the World *
|
||||
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
|
||||
* obtain it by writing to the Free Software Foundation, *
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
* *
|
||||
***************************************************************************
|
||||
}
|
||||
unit ProcessList;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Process;
|
||||
|
||||
type
|
||||
{ The TProcessList is used by the IDE to store all running programs and
|
||||
external tools, that are not watched. From time to time the IDE checks,
|
||||
if the processes has terminated and will free them cleanly to avoid
|
||||
zombies. }
|
||||
TProcessList = class
|
||||
private
|
||||
FItems: TList; // list of TProcess
|
||||
function GetCount: integer;
|
||||
function GetItems(Index: integer): TProcess;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
function Add(NewProcess: TProcess): integer;
|
||||
procedure Clear;
|
||||
procedure FreeStoppedProcesses;
|
||||
public
|
||||
property Count: integer read GetCount;
|
||||
property Items[Index: integer]: TProcess read GetItems; default;
|
||||
end;
|
||||
|
||||
function GetDefaultProcessList: TProcessList;
|
||||
|
||||
implementation
|
||||
|
||||
var
|
||||
DefaultProcessList: TProcessList;
|
||||
|
||||
function GetDefaultProcessList: TProcessList;
|
||||
begin
|
||||
if DefaultProcessList=nil then DefaultProcessList:=TProcessList.Create;
|
||||
Result:=DefaultProcessList;
|
||||
end;
|
||||
|
||||
{ TProcessList }
|
||||
|
||||
function TProcessList.GetCount: integer;
|
||||
begin
|
||||
Result:=FItems.Count;
|
||||
end;
|
||||
|
||||
function TProcessList.GetItems(Index: integer): TProcess;
|
||||
begin
|
||||
Result:=TProcess(FItems[Index]);
|
||||
end;
|
||||
|
||||
constructor TProcessList.Create;
|
||||
begin
|
||||
FItems:=TList.Create;
|
||||
end;
|
||||
|
||||
destructor TProcessList.Destroy;
|
||||
begin
|
||||
Clear;
|
||||
FItems.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TProcessList.Add(NewProcess: TProcess): integer;
|
||||
begin
|
||||
Result:=FItems.Add(NewProcess);
|
||||
end;
|
||||
|
||||
procedure TProcessList.Clear;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i:=0 to FItems.Count-1 do
|
||||
Items[i].Free;
|
||||
FItems.Clear;
|
||||
end;
|
||||
|
||||
procedure TProcessList.FreeStoppedProcesses;
|
||||
var
|
||||
AProcess: TProcess;
|
||||
i: Integer;
|
||||
begin
|
||||
for i:=FItems.Count-1 downto 0 do begin
|
||||
AProcess:=Items[i];
|
||||
if AProcess.Running then continue;
|
||||
try
|
||||
try
|
||||
AProcess.WaitOnExit;
|
||||
AProcess.Free;
|
||||
finally
|
||||
FItems.Delete(i);
|
||||
end;
|
||||
except
|
||||
on E: Exception do begin
|
||||
writeln('Error freeing stopped process: ',E.Message);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
DefaultProcessList:=nil;
|
||||
|
||||
finalization
|
||||
DefaultProcessList.Free;
|
||||
DefaultProcessList:=nil;
|
||||
|
||||
end.
|
||||
|
164
ide/clipboardhistory.pas
Normal file
164
ide/clipboardhistory.pas
Normal file
@ -0,0 +1,164 @@
|
||||
{
|
||||
/***************************************************************************
|
||||
ClipBoardHistory.pas
|
||||
--------------------
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* This source is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This code is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* General Public License for more details. *
|
||||
* *
|
||||
* A copy of the GNU General Public License is available on the World *
|
||||
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
|
||||
* obtain it by writing to the Free Software Foundation, *
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
Author: Mattias Gaertner
|
||||
|
||||
Abstract:
|
||||
The TClipBoardHistory form a front end for clipboard history, which stores
|
||||
the texts of the last copy to clipboard actions.
|
||||
|
||||
ToDo:
|
||||
Everything.
|
||||
}
|
||||
unit ClipBoardHistory;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Buttons, SynEdit, EditorOptions, StdCtrls,
|
||||
IDEOptionDefs, Math, EnvironmentOpts, ClipBrd;
|
||||
|
||||
type
|
||||
TClipBoardHistory = class(TForm)
|
||||
CopyToIDEBitBtn: TBitBtn;
|
||||
ClearBitBtn: TBitBtn;
|
||||
PasteFromClipboardBitBtn: TBitBtn;
|
||||
ItemsListBox: TListBox;
|
||||
PreviewSynEdit: TSynEdit;
|
||||
procedure ClipBoardHistoryResize(Sender: TObject);
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TClipBoardHistory }
|
||||
|
||||
procedure TClipBoardHistory.ClipBoardHistoryResize(Sender: TObject);
|
||||
begin
|
||||
with CopyToIDEBitBtn do begin
|
||||
Left:=0;
|
||||
Top:=0;
|
||||
end;
|
||||
|
||||
with ClearBitBtn do begin
|
||||
Left:=CopyToIDEBitBtn.Left+CopyToIDEBitBtn.Width;
|
||||
Top:=0;
|
||||
end;
|
||||
|
||||
with PasteFromClipboardBitBtn do begin
|
||||
Left:=ClearBitBtn.Left+ClearBitBtn.Width;
|
||||
Top:=0;
|
||||
end;
|
||||
|
||||
with ItemsListBox do begin
|
||||
Left:=0;
|
||||
Top:=CopyToIDEBitBtn.Top+CopyToIDEBitBtn.Height;
|
||||
Width:=Self.ClientWidth;
|
||||
Height:=Max(Self.ClientHeight-Top-100,30);
|
||||
end;
|
||||
|
||||
with PreviewSynEdit do begin
|
||||
Left:=0;
|
||||
Top:=ItemsListBox.Top+ItemsListBox.Height;
|
||||
Width:=Self.ClientWidth;
|
||||
Height:=Self.ClientHeight-Top;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TClipBoardHistory.Create(TheOwner: TComponent);
|
||||
var
|
||||
ALayout: TIDEWindowLayout;
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
|
||||
Name:=DefaultClipbrdHistoryName;
|
||||
Caption := 'Clipboard History';
|
||||
ALayout:=EnvironmentOptions.IDEWindowLayoutList.ItemByFormID(Name);
|
||||
ALayout.Form:=TForm(Self);
|
||||
ALayout.Apply;
|
||||
|
||||
|
||||
CopyToIDEBitBtn:=TBitBtn.Create(Self);
|
||||
with CopyToIDEBitBtn do begin
|
||||
Name:='CopyToIDEBitBtn';
|
||||
Parent:=Self;
|
||||
Left:=0;
|
||||
Top:=0;
|
||||
Caption:='Copy to IDE';
|
||||
end;
|
||||
|
||||
ClearBitBtn:=TBitBtn.Create(Self);
|
||||
with ClearBitBtn do begin
|
||||
Name:='ClearBitBtn';
|
||||
Parent:=Self;
|
||||
Left:=CopyToIDEBitBtn.Left+CopyToIDEBitBtn.Width;
|
||||
Top:=0;
|
||||
Caption:='Clear all';
|
||||
end;
|
||||
|
||||
PasteFromClipboardBitBtn:=TBitBtn.Create(Self);
|
||||
with PasteFromClipboardBitBtn do begin
|
||||
Name:='PasteFromClipboardBitBtn';
|
||||
Parent:=Self;
|
||||
Left:=ClearBitBtn.Left+ClearBitBtn.Width;
|
||||
Top:=0;
|
||||
Caption:='Paste from Clipboard';
|
||||
end;
|
||||
|
||||
ItemsListBox:=TListBox.Create(Self);
|
||||
with ItemsListBox do begin
|
||||
Name:='ItemsListBox';
|
||||
Parent:=Self;
|
||||
Left:=0;
|
||||
Top:=CopyToIDEBitBtn.Top+CopyToIDEBitBtn.Height;
|
||||
Width:=Self.ClientWidth;
|
||||
Height:=Max(Self.ClientHeight-Top-100,30);
|
||||
end;
|
||||
|
||||
PreviewSynEdit:=TSynEdit.Create(Self);
|
||||
with PreviewSynEdit do begin
|
||||
Name:='PreviewSynEdit';
|
||||
Parent:=Self;
|
||||
Left:=0;
|
||||
Top:=ItemsListBox.Top+ItemsListBox.Height;
|
||||
Width:=Self.ClientWidth;
|
||||
Height:=Self.ClientHeight-Top;
|
||||
end;
|
||||
|
||||
OnResize:=@ClipBoardHistoryResize;
|
||||
end;
|
||||
|
||||
destructor TClipBoardHistory.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
14
ide/main.pp
14
ide/main.pp
@ -54,7 +54,8 @@ uses
|
||||
LMessages, ProjectDefs, Watchesdlg, BreakPointsdlg, ColumnDlg, OutputFilter,
|
||||
BuildLazDialog, MiscOptions, EditDefineTree, CodeToolsOptions, TypInfo,
|
||||
IDEOptionDefs, CodeToolsDefines, LocalsDlg, DebuggerDlg, InputHistory,
|
||||
DiskDiffsDialog, UnitDependencies, PublishProjectDlg,
|
||||
DiskDiffsDialog, UnitDependencies, PublishProjectDlg, ClipBoardHistory,
|
||||
ProcessList,
|
||||
// main ide
|
||||
BaseDebugManager, DebugManager, MainBar;
|
||||
|
||||
@ -5109,6 +5110,9 @@ begin
|
||||
try
|
||||
Writeln(' EXECUTING "',FRunProcess.CommandLine,'"');
|
||||
Writeln(' WorkingDir "',FRunProcess.CurrentDirectory,'"');
|
||||
// just run the program and don't care (no watch, no debugging)
|
||||
// just check from time to time, if it has terminated and clean up
|
||||
GetDefaultProcessList.Add(FRunProcess);
|
||||
FRunProcess.Execute;
|
||||
ToolStatus:=itNone;
|
||||
Result := mrOk;
|
||||
@ -7110,6 +7114,8 @@ end;
|
||||
procedure TMainIDE.OnApplicationIdle(Sender: TObject);
|
||||
begin
|
||||
UpdateWindowsMenu;
|
||||
GetDefaultProcessList.FreeStoppedProcesses;
|
||||
EnvironmentOptions.ExternalTools.FreeStoppedProcesses;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.OnExtToolNeedsOutputFilter(var OutputFilter: TOutputFilter;
|
||||
@ -7545,6 +7551,9 @@ begin
|
||||
if ALayout.FormID=DefaultCodeExplorerName then begin
|
||||
ALayout.Form.SetBounds(Screen.Width-200,130,170,Max(50,Screen.Height-230));
|
||||
end else
|
||||
if ALayout.FormID=DefaultClipbrdHistoryName then begin
|
||||
ALayout.Form.SetBounds(250,Screen.Height-400,400,300);
|
||||
end else
|
||||
if ALayout.FormID=DefaultMessagesViewName then begin
|
||||
ALayout.Form.SetBounds(260,SourceNotebook.Top+SourceNotebook.Height+30,
|
||||
Max(50,Screen.Width-300),80);
|
||||
@ -7589,6 +7598,9 @@ end.
|
||||
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.450 2003/01/06 10:51:40 mattias
|
||||
freeing stopped external tools
|
||||
|
||||
Revision 1.449 2003/01/04 11:58:32 mattias
|
||||
added Windows menu to IDE
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user