IdeIntf: New notify handler RunFinished. Issue #32617, patch from Pascal Riekenberg.

git-svn-id: trunk@56254 -
This commit is contained in:
juha 2017-10-31 21:13:40 +00:00
parent 98765f8769
commit 0e07a10a03
5 changed files with 86 additions and 7 deletions

1
.gitattributes vendored
View File

@ -6592,6 +6592,7 @@ ide/newdialog.lfm svneol=native#text/plain
ide/newdialog.pas svneol=native#text/pascal ide/newdialog.pas svneol=native#text/pascal
ide/newprojectdlg.lfm svneol=native#text/plain ide/newprojectdlg.lfm svneol=native#text/plain
ide/newprojectdlg.pp svneol=native#text/pascal ide/newprojectdlg.pp svneol=native#text/pascal
ide/notifyprocessend.pas svneol=native#text/pascal
ide/objectlists.pas svneol=native#text/pascal ide/objectlists.pas svneol=native#text/pascal
ide/patheditordlg.lfm svneol=native#text/pascal ide/patheditordlg.lfm svneol=native#text/pascal
ide/patheditordlg.pas svneol=native#text/pascal ide/patheditordlg.pas svneol=native#text/pascal

View File

@ -246,7 +246,8 @@ type
lihtGetFPCFrontEndPath, // called when the IDE gets the path of the 'fpc' front end tool lihtGetFPCFrontEndPath, // called when the IDE gets the path of the 'fpc' front end tool
lihtShowDesignerFormOfSource, // called after showing a designer form for code editor (AEditor can be nil!) lihtShowDesignerFormOfSource, // called after showing a designer form for code editor (AEditor can be nil!)
lihtShowSourceOfActiveDesignerForm, // called after showing a code of designer form lihtShowSourceOfActiveDesignerForm, // called after showing a code of designer form
lihtChangeToolStatus//called when IDEToolStatus has changed (e.g. itNone->itBuilder etc.) lihtChangeToolStatus, //called when IDEToolStatus has changed (e.g. itNone->itBuilder etc.)
lihtRunFinished //called when ran program finishes
); );
TLazToolStatus = ( TLazToolStatus = (
@ -377,6 +378,7 @@ type
function GetProjectFileForProjectEditor(AEditor: TSourceEditorInterface): TLazProjectFile; virtual; abstract; function GetProjectFileForProjectEditor(AEditor: TSourceEditorInterface): TLazProjectFile; virtual; abstract;
function DoCallProjectChangedHandler(HandlerType: TLazarusIDEHandlerType; function DoCallProjectChangedHandler(HandlerType: TLazarusIDEHandlerType;
AProject: TLazProject): TModalResult; AProject: TLazProject): TModalResult;
procedure DoCallRunFinishedHandler;
function DoAddUnitToProject(AEditor: TSourceEditorInterface): TModalResult; virtual; abstract; function DoAddUnitToProject(AEditor: TSourceEditorInterface): TModalResult; virtual; abstract;
// configs // configs
@ -512,8 +514,7 @@ type
function CallHandlerGetFPCFrontEndParams(Sender: TObject; var Params: string): boolean; function CallHandlerGetFPCFrontEndParams(Sender: TObject; var Params: string): boolean;
procedure AddHandlerGetFPCFrontEndPath( procedure AddHandlerGetFPCFrontEndPath(
const Handler: TGetFPCFrontEndPath; AsLast: boolean = false); const Handler: TGetFPCFrontEndPath; AsLast: boolean = false);
procedure RemoveHandlerGetFPCFrontEndPath( procedure RemoveHandlerGetFPCFrontEndPath(const Handler: TGetFPCFrontEndPath);
const Handler: TGetFPCFrontEndPath);
function CallHandlerGetFPCFrontEndPath(Sender: TObject; var Path: string): boolean; function CallHandlerGetFPCFrontEndPath(Sender: TObject; var Path: string): boolean;
procedure AddHandlerOnShowDesignerFormOfSource( procedure AddHandlerOnShowDesignerFormOfSource(
const OnShowDesignerFormOfSourceEvent: TShowDesignerFormOfSourceFunction; const OnShowDesignerFormOfSourceEvent: TShowDesignerFormOfSourceFunction;
@ -530,6 +531,9 @@ type
AsLast: boolean = false); AsLast: boolean = false);
procedure RemoveHandlerOnChangeToolStatus( procedure RemoveHandlerOnChangeToolStatus(
const OnChangeToolStatus: TLazToolStatusChangeEvent); const OnChangeToolStatus: TLazToolStatusChangeEvent);
procedure AddHandlerOnRunFinished(const OnRunFinishedEvent: TNotifyEvent;
AsLast: boolean = false);
procedure RemoveHandlerOnRunFinished(const OnRunFinishedEvent: TNotifyEvent);
property IDEStarted: boolean read FIDEStarted; property IDEStarted: boolean read FIDEStarted;
property IDEIsClosing: boolean read FIDEIsClosing; property IDEIsClosing: boolean read FIDEIsClosing;
@ -765,6 +769,11 @@ begin
end; end;
end; end;
procedure TLazIDEInterface.DoCallRunFinishedHandler;
begin
DoCallNotifyHandler(lihtRunFinished);
end;
procedure TLazIDEInterface.RemoveAllHandlersOfObject(AnObject: TObject); procedure TLazIDEInterface.RemoveAllHandlersOfObject(AnObject: TObject);
var var
HandlerType: TLazarusIDEHandlerType; HandlerType: TLazarusIDEHandlerType;
@ -995,6 +1004,18 @@ begin
RemoveHandler(lihtChangeToolStatus,TMethod(OnChangeToolStatus)); RemoveHandler(lihtChangeToolStatus,TMethod(OnChangeToolStatus));
end; end;
procedure TLazIDEInterface.AddHandlerOnRunFinished(
const OnRunFinishedEvent: TNotifyEvent; AsLast: boolean);
begin
AddHandler(lihtRunFinished,TMethod(OnRunFinishedEvent),AsLast);
end;
procedure TLazIDEInterface.RemoveHandlerOnRunFinished(
const OnRunFinishedEvent: TNotifyEvent);
begin
RemoveHandler(lihtRunFinished,TMethod(OnRunFinishedEvent));
end;
function TLazIDEInterface.CallHandlerGetFPCFrontEndPath(Sender: TObject; function TLazIDEInterface.CallHandlerGetFPCFrontEndPath(Sender: TObject;
var Path: string): boolean; var Path: string): boolean;
var var

View File

@ -1250,6 +1250,7 @@ begin
FPrevShownWindow:=0; FPrevShownWindow:=0;
if (OldState<>dsIdle) if (OldState<>dsIdle)
then begin then begin
MainIDE.DoCallRunFinishedHandler;
if EnvironmentOptions.DebuggerShowStopMessage if EnvironmentOptions.DebuggerShowStopMessage
then begin then begin
MsgResult:=IDEQuestionDialog(lisExecutionStopped, MsgResult:=IDEQuestionDialog(lisExecutionStopped,

View File

@ -59,7 +59,7 @@ uses
MemCheck, MemCheck,
{$ENDIF} {$ENDIF}
// fpc packages // fpc packages
Math, Classes, SysUtils, TypInfo, types, strutils, Laz_AVL_Tree, Math, Classes, SysUtils, TypInfo, types, strutils, process, Laz_AVL_Tree,
// LCL // LCL
LCLProc, LCLType, LCLIntf, LResources, HelpIntfs, InterfaceBase, LCLPlatformDef, LCLProc, LCLType, LCLIntf, LResources, HelpIntfs, InterfaceBase, LCLPlatformDef,
ComCtrls, Forms, Buttons, Menus, Controls, GraphType, Graphics, ExtCtrls, ComCtrls, Forms, Buttons, Menus, Controls, GraphType, Graphics, ExtCtrls,
@ -155,7 +155,7 @@ uses
CleanDirDlg, CodeContextForm, AboutFrm, CompatibilityRestrictions, CleanDirDlg, CodeContextForm, AboutFrm, CompatibilityRestrictions,
RestrictionBrowser, ProjectWizardDlg, IDECmdLine, IDEGuiCmdLine, CodeExplOpts, RestrictionBrowser, ProjectWizardDlg, IDECmdLine, IDEGuiCmdLine, CodeExplOpts,
EditorMacroListViewer, SourceFileManager, EditorToolbarStatic, EditorMacroListViewer, SourceFileManager, EditorToolbarStatic,
IDEInstances, process, IDEInstances, NotifyProcessEnd,
// main ide // main ide
MainBar, MainIntf, MainBase; MainBar, MainIntf, MainBase;
@ -7092,8 +7092,8 @@ begin
Exit(mrNone); Exit(mrNone);
end; end;
Process.Execute; TNotifyProcessEnd.Create(Process, @DoCallRunFinishedHandler);
finally except
Process.Free; Process.Free;
end; end;
end; end;

56
ide/notifyprocessend.pas Normal file
View File

@ -0,0 +1,56 @@
{
*****************************************************************************
See the file COPYING.modifiedLGPL.txt, included in this distribution,
for details about the license.
*****************************************************************************
Author: Pascal Riekenberg
Abstract:
Provides a general classes for calling an event when a process ends
}
unit NotifyProcessEnd;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, process;
type
{ TNotifyProcessEnd }
TNotifyProcessEnd = class(TThread)
private
fEvent: TThreadMethod;
fProcess: TProcess;
protected
procedure Execute; override;
public
constructor Create(pProcess: TProcess; pEvent: TThreadMethod);
end;
implementation
{ TNotifyProcessEnd }
procedure TNotifyProcessEnd.Execute;
begin
fProcess.Execute;
Synchronize(fEvent);
fProcess.Free;
end;
constructor TNotifyProcessEnd.Create(pProcess: TProcess; pEvent: TThreadMethod);
begin
inherited Create(True);
fProcess := pProcess;
fProcess.Options := fProcess.Options + [poWaitOnExit];
fEvent := pEvent;
FreeOnTerminate := True;
Start;
end;
end.