TCEMainForm: uses new TCEProcess

see b911e10e93
This commit is contained in:
Basile Burg 2015-07-15 14:29:18 +02:00
parent 9bb01032b6
commit 6ece0bf0aa
1 changed files with 16 additions and 26 deletions

View File

@ -11,7 +11,7 @@ uses
ce_common, ce_dmdwrap, ce_nativeproject, ce_dcd, ce_synmemo, ce_writableComponent, ce_common, ce_dmdwrap, ce_nativeproject, ce_dcd, ce_synmemo, ce_writableComponent,
ce_widget, ce_messages, ce_interfaces, ce_editor, ce_projinspect, ce_projconf, ce_widget, ce_messages, ce_interfaces, ce_editor, ce_projinspect, ce_projconf,
ce_search, ce_miniexplorer, ce_libman, ce_libmaneditor, ce_todolist, ce_observer, ce_search, ce_miniexplorer, ce_libman, ce_libmaneditor, ce_todolist, ce_observer,
ce_toolseditor, ce_procinput, ce_optionseditor, ce_symlist, ce_mru; ce_toolseditor, ce_procinput, ce_optionseditor, ce_symlist, ce_mru, ce_processes;
type type
@ -208,7 +208,7 @@ type
fInitialized: boolean; fInitialized: boolean;
fRunnableSw: string; fRunnableSw: string;
fRunProc: TCheckedAsyncProcess; fRunProc: TCEProcess;
fMsgs: ICEMessagesDisplay; fMsgs: ICEMessagesDisplay;
fMainMenuSubj: TCEMainMenuSubject; fMainMenuSubj: TCEMainMenuSubject;
procedure updateMainMenuProviders; procedure updateMainMenuProviders;
@ -1296,14 +1296,15 @@ end;
{$REGION run -------------------------------------------------------------------} {$REGION run -------------------------------------------------------------------}
procedure TCEMainForm.asyncprocOutput(sender: TObject); procedure TCEMainForm.asyncprocOutput(sender: TObject);
var var
proc: TProcess; proc: TCEProcess;
lst: TStringList; lst: TStringList;
str: string; str: string;
begin begin
proc := TProcess(sender); proc := TCEProcess(sender);
lst := TStringList.Create; lst := TStringList.Create;
try try
processOutputToStrings(proc, lst); proc.getFullLines(lst);
//processOutputToStrings(proc, lst);
if proc = fRunProc then for str in lst do if proc = fRunProc then for str in lst do
fMsgs.message(str, fDoc, amcEdit, amkBub) fMsgs.message(str, fDoc, amcEdit, amkBub)
else if proc.Executable = DCompiler then else if proc.Executable = DCompiler then
@ -1316,24 +1317,11 @@ end;
procedure TCEMainForm.asyncprocTerminate(sender: TObject); procedure TCEMainForm.asyncprocTerminate(sender: TObject);
var var
proc: TProcess; proc: TCEProcess;
lst: TStringList;
str: string;
inph: TObject; inph: TObject;
begin begin
proc := TProcess(sender); proc := TCEProcess(sender);
lst := TStringList.Create; asyncprocOutput(sender);
try
processOutputToStrings(proc, lst);
// runnable module
if proc = fRunProc then
begin
for str in lst do
fMsgs.message(str, fDoc, amcEdit, amkBub);
end;
finally
lst.Free;
end;
inph := EntitiesConnector.getSingleService('ICEProcInputHandler'); inph := EntitiesConnector.getSingleService('ICEProcInputHandler');
if (inph <> nil) then if (inph <> nil) then
(inph as ICEProcInputHandler).removeProcess(proc); (inph as ICEProcInputHandler).removeProcess(proc);
@ -1389,7 +1377,7 @@ end;
procedure TCEMainForm.compileAndRunFile(unittest: boolean = false; redirect: boolean = true; procedure TCEMainForm.compileAndRunFile(unittest: boolean = false; redirect: boolean = true;
const runArgs: string = ''); const runArgs: string = '');
var var
dmdproc: TProcess; dmdproc: TCEProcess;
fname: string; fname: string;
begin begin
@ -1397,7 +1385,7 @@ begin
FreeRunnableProc; FreeRunnableProc;
if fDoc = nil then exit; if fDoc = nil then exit;
fRunProc := TCheckedAsyncProcess.Create(nil); fRunProc := TCEProcess.Create(nil);
if redirect then if redirect then
begin begin
fRunProc.Options := [poStderrToOutPut, poUsePipes]; fRunProc.Options := [poStderrToOutPut, poUsePipes];
@ -1411,7 +1399,7 @@ begin
{$ENDIF} {$ENDIF}
end; end;
dmdproc := TProcess.Create(nil); dmdproc := TCEProcess.Create(nil);
try try
fMsgs.message('compiling ' + shortenPath(fDoc.fileName, 25), fDoc, amcEdit, amkInf); fMsgs.message('compiling ' + shortenPath(fDoc.fileName, 25), fDoc, amcEdit, amkInf);
@ -1425,6 +1413,8 @@ begin
{$IFDEF RELEASE} {$IFDEF RELEASE}
dmdProc.ShowWindow := swoHIDE; dmdProc.ShowWindow := swoHIDE;
{$ENDIF} {$ENDIF}
dmdproc.OnReadData := @asyncprocOutput;
dmdproc.OnTerminate:= @asyncprocTerminate;
dmdproc.Options := [poStdErrToOutput, poUsePipes]; dmdproc.Options := [poStdErrToOutput, poUsePipes];
dmdproc.Executable := DCompiler; dmdproc.Executable := DCompiler;
dmdproc.Parameters.Add(fDoc.fileName); dmdproc.Parameters.Add(fDoc.fileName);
@ -1440,8 +1430,8 @@ begin
LibMan.getLibFiles(nil, dmdproc.Parameters); LibMan.getLibFiles(nil, dmdproc.Parameters);
LibMan.getLibSources(nil, dmdproc.Parameters); LibMan.getLibSources(nil, dmdproc.Parameters);
dmdproc.Execute; dmdproc.Execute;
while dmdproc.Running do; while dmdproc.Running do
asyncprocOutput(dmdProc); application.ProcessMessages;
if (dmdProc.ExitStatus = 0) then if (dmdProc.ExitStatus = 0) then
begin begin