changed action updater

realted to linux bugs:
- doc close, AV
- TColorPropertyEditor convert error
This commit is contained in:
Basile Burg 2015-03-13 14:46:56 +01:00
parent 389ff729db
commit e4656ca9e7
2 changed files with 54 additions and 85 deletions

View File

@ -2074,6 +2074,7 @@ object CEMainForm: TCEMainForm
Caption = 'Copy' Caption = 'Copy'
ImageIndex = 4 ImageIndex = 4
OnExecute = actEdCopyExecute OnExecute = actEdCopyExecute
OnUpdate = updateDocumentBasedAction
ShortCut = 16451 ShortCut = 16451
end end
object actEdCut: TAction object actEdCut: TAction
@ -2081,6 +2082,7 @@ object CEMainForm: TCEMainForm
Caption = 'Cut' Caption = 'Cut'
ImageIndex = 6 ImageIndex = 6
OnExecute = actEdCutExecute OnExecute = actEdCutExecute
OnUpdate = updateDocumentBasedAction
ShortCut = 16472 ShortCut = 16472
end end
object actEdPaste: TAction object actEdPaste: TAction
@ -2088,6 +2090,7 @@ object CEMainForm: TCEMainForm
Caption = 'Paste' Caption = 'Paste'
ImageIndex = 5 ImageIndex = 5
OnExecute = actEdPasteExecute OnExecute = actEdPasteExecute
OnUpdate = updateDocumentBasedAction
ShortCut = 16470 ShortCut = 16470
end end
object actEdUndo: TAction object actEdUndo: TAction
@ -2095,6 +2098,7 @@ object CEMainForm: TCEMainForm
Caption = 'Undo' Caption = 'Undo'
ImageIndex = 0 ImageIndex = 0
OnExecute = actEdUndoExecute OnExecute = actEdUndoExecute
OnUpdate = updateDocumentBasedAction
ShortCut = 16474 ShortCut = 16474
end end
object actEdRedo: TAction object actEdRedo: TAction
@ -2102,6 +2106,7 @@ object CEMainForm: TCEMainForm
Caption = 'Redo' Caption = 'Redo'
ImageIndex = 1 ImageIndex = 1
OnExecute = actEdRedoExecute OnExecute = actEdRedoExecute
OnUpdate = updateDocumentBasedAction
ShortCut = 24666 ShortCut = 24666
end end
object actEdMacStartStop: TAction object actEdMacStartStop: TAction
@ -2109,6 +2114,7 @@ object CEMainForm: TCEMainForm
Caption = 'Start/stop macro recording' Caption = 'Start/stop macro recording'
ImageIndex = 10 ImageIndex = 10
OnExecute = actEdMacStartStopExecute OnExecute = actEdMacStartStopExecute
OnUpdate = updateDocumentBasedAction
ShortCut = 24658 ShortCut = 24658
end end
object actEdMacPlay: TAction object actEdMacPlay: TAction
@ -2116,6 +2122,7 @@ object CEMainForm: TCEMainForm
Caption = 'Play macro' Caption = 'Play macro'
ImageIndex = 11 ImageIndex = 11
OnExecute = actEdMacPlayExecute OnExecute = actEdMacPlayExecute
OnUpdate = updateDocumentBasedAction
ShortCut = 24656 ShortCut = 24656
end end
object actFileSave: TAction object actFileSave: TAction
@ -2123,6 +2130,7 @@ object CEMainForm: TCEMainForm
Caption = 'Save file' Caption = 'Save file'
ImageIndex = 3 ImageIndex = 3
OnExecute = actFileSaveExecute OnExecute = actFileSaveExecute
OnUpdate = updateDocumentBasedAction
ShortCut = 16467 ShortCut = 16467
end end
object actFileSaveAs: TAction object actFileSaveAs: TAction
@ -2130,6 +2138,7 @@ object CEMainForm: TCEMainForm
Caption = 'Save file as...' Caption = 'Save file as...'
ImageIndex = 2 ImageIndex = 2
OnExecute = actFileSaveAsExecute OnExecute = actFileSaveAsExecute
OnUpdate = updateDocumentBasedAction
ShortCut = 49235 ShortCut = 49235
end end
object actFileOpen: TAction object actFileOpen: TAction
@ -2158,12 +2167,14 @@ object CEMainForm: TCEMainForm
Caption = 'Add file to project' Caption = 'Add file to project'
ImageIndex = 7 ImageIndex = 7
OnExecute = actFileAddToProjExecute OnExecute = actFileAddToProjExecute
OnUpdate = updateDocumentBasedAction
end end
object actFileCompAndRun: TAction object actFileCompAndRun: TAction
Category = 'File' Category = 'File'
Caption = 'Compile file and run' Caption = 'Compile file and run'
ImageIndex = 22 ImageIndex = 22
OnExecute = actFileCompAndRunExecute OnExecute = actFileCompAndRunExecute
OnUpdate = updateDocumentBasedAction
ShortCut = 16503 ShortCut = 16503
end end
object actProjSave: TAction object actProjSave: TAction
@ -2171,12 +2182,14 @@ object CEMainForm: TCEMainForm
Caption = 'Save project' Caption = 'Save project'
ImageIndex = 3 ImageIndex = 3
OnExecute = actProjSaveExecute OnExecute = actProjSaveExecute
OnUpdate = updateProjectBasedAction
end end
object actProjSaveAs: TAction object actProjSaveAs: TAction
Category = 'Project' Category = 'Project'
Caption = 'Save project as...' Caption = 'Save project as...'
ImageIndex = 2 ImageIndex = 2
OnExecute = actProjSaveAsExecute OnExecute = actProjSaveAsExecute
OnUpdate = updateProjectBasedAction
end end
object actProjOpen: TAction object actProjOpen: TAction
Category = 'Project' Category = 'Project'
@ -2195,24 +2208,28 @@ object CEMainForm: TCEMainForm
Caption = 'Close project' Caption = 'Close project'
ImageIndex = 27 ImageIndex = 27
OnExecute = actProjCloseExecute OnExecute = actProjCloseExecute
OnUpdate = updateProjectBasedAction
end end
object actProjOpts: TAction object actProjOpts: TAction
Category = 'Project' Category = 'Project'
Caption = 'Project configuration' Caption = 'Project configuration'
ImageIndex = 24 ImageIndex = 24
OnExecute = actProjOptsExecute OnExecute = actProjOptsExecute
OnUpdate = updateProjectBasedAction
end end
object actProjSource: TAction object actProjSource: TAction
Category = 'Project' Category = 'Project'
Caption = 'View project source' Caption = 'View project source'
ImageIndex = 12 ImageIndex = 12
OnExecute = actProjSourceExecute OnExecute = actProjSourceExecute
OnUpdate = updateProjectBasedAction
end end
object actEdIndent: TAction object actEdIndent: TAction
Category = 'Edit' Category = 'Edit'
Caption = 'Indent' Caption = 'Indent'
ImageIndex = 16 ImageIndex = 16
OnExecute = actEdIndentExecute OnExecute = actEdIndentExecute
OnUpdate = updateDocumentBasedAction
ShortCut = 24649 ShortCut = 24649
end end
object actEdUnIndent: TAction object actEdUnIndent: TAction
@ -2220,6 +2237,7 @@ object CEMainForm: TCEMainForm
Caption = 'Unindent' Caption = 'Unindent'
ImageIndex = 17 ImageIndex = 17
OnExecute = actEdUnIndentExecute OnExecute = actEdUnIndentExecute
OnUpdate = updateDocumentBasedAction
ShortCut = 24661 ShortCut = 24661
end end
object actProjOptView: TAction object actProjOptView: TAction
@ -2227,12 +2245,14 @@ object CEMainForm: TCEMainForm
Caption = 'View project command line' Caption = 'View project command line'
ImageIndex = 12 ImageIndex = 12
OnExecute = actProjOptViewExecute OnExecute = actProjOptViewExecute
OnUpdate = updateProjectBasedAction
end end
object actProjCompile: TAction object actProjCompile: TAction
Category = 'Project' Category = 'Project'
Caption = 'Compile project' Caption = 'Compile project'
ImageIndex = 21 ImageIndex = 21
OnExecute = actProjCompileExecute OnExecute = actProjCompileExecute
OnUpdate = updateProjectBasedAction
ShortCut = 16504 ShortCut = 16504
end end
object actProjCompileAndRun: TAction object actProjCompileAndRun: TAction
@ -2240,6 +2260,7 @@ object CEMainForm: TCEMainForm
Caption = 'Compile project and run' Caption = 'Compile project and run'
ImageIndex = 21 ImageIndex = 21
OnExecute = actProjCompileAndRunExecute OnExecute = actProjCompileAndRunExecute
OnUpdate = updateProjectBasedAction
ShortCut = 24696 ShortCut = 24696
end end
object actProjCompAndRunWithArgs: TAction object actProjCompAndRunWithArgs: TAction
@ -2247,12 +2268,14 @@ object CEMainForm: TCEMainForm
Caption = 'Compile project and run...' Caption = 'Compile project and run...'
ImageIndex = 21 ImageIndex = 21
OnExecute = actProjCompAndRunWithArgsExecute OnExecute = actProjCompAndRunWithArgsExecute
OnUpdate = updateProjectBasedAction
end end
object actProjRun: TAction object actProjRun: TAction
Category = 'Project' Category = 'Project'
Caption = 'Run project' Caption = 'Run project'
ImageIndex = 21 ImageIndex = 21
OnExecute = actProjRunExecute OnExecute = actProjRunExecute
OnUpdate = updateProjectBasedAction
ShortCut = 120 ShortCut = 120
end end
object actProjRunWithArgs: TAction object actProjRunWithArgs: TAction
@ -2260,12 +2283,14 @@ object CEMainForm: TCEMainForm
Caption = 'Run project...' Caption = 'Run project...'
ImageIndex = 21 ImageIndex = 21
OnExecute = actProjRunWithArgsExecute OnExecute = actProjRunWithArgsExecute
OnUpdate = updateProjectBasedAction
end end
object actEdFind: TAction object actEdFind: TAction
Category = 'Edit' Category = 'Edit'
Caption = 'Find...' Caption = 'Find...'
ImageIndex = 28 ImageIndex = 28
OnExecute = actEdFindExecute OnExecute = actEdFindExecute
OnUpdate = updateDocumentBasedAction
ShortCut = 16454 ShortCut = 16454
end end
object actEdFindNext: TAction object actEdFindNext: TAction
@ -2273,6 +2298,7 @@ object CEMainForm: TCEMainForm
Caption = 'Find next' Caption = 'Find next'
ImageIndex = 28 ImageIndex = 28
OnExecute = actEdFindNextExecute OnExecute = actEdFindNextExecute
OnUpdate = updateDocumentBasedAction
ShortCut = 114 ShortCut = 114
end end
object actProjOpenContFold: TAction object actProjOpenContFold: TAction
@ -2280,6 +2306,7 @@ object CEMainForm: TCEMainForm
Caption = 'View in mini explorer' Caption = 'View in mini explorer'
ImageIndex = 29 ImageIndex = 29
OnExecute = actProjOpenContFoldExecute OnExecute = actProjOpenContFoldExecute
OnUpdate = updateProjectBasedAction
end end
object actLayoutSave: TAction object actLayoutSave: TAction
Category = 'Misc' Category = 'Misc'
@ -2292,12 +2319,14 @@ object CEMainForm: TCEMainForm
Caption = 'Compile file and run outside' Caption = 'Compile file and run outside'
ImageIndex = 22 ImageIndex = 22
OnExecute = actFileCompileAndRunOutExecute OnExecute = actFileCompileAndRunOutExecute
OnUpdate = updateDocumentBasedAction
end end
object ActFileCompAndRunWithArgs: TAction object ActFileCompAndRunWithArgs: TAction
Category = 'File' Category = 'File'
Caption = 'Compile file and run...' Caption = 'Compile file and run...'
ImageIndex = 22 ImageIndex = 22
OnExecute = ActFileCompAndRunWithArgsExecute OnExecute = ActFileCompAndRunWithArgsExecute
OnUpdate = updateDocumentBasedAction
ShortCut = 24695 ShortCut = 24695
end end
object actFileSaveAll: TAction object actFileSaveAll: TAction
@ -2305,12 +2334,14 @@ object CEMainForm: TCEMainForm
Caption = 'Save all' Caption = 'Save all'
ImageIndex = 26 ImageIndex = 26
OnExecute = actFileSaveAllExecute OnExecute = actFileSaveAllExecute
OnUpdate = updateDocumentBasedAction
end end
object actFileClose: TAction object actFileClose: TAction
Category = 'File' Category = 'File'
Caption = 'Close file' Caption = 'Close file'
ImageIndex = 27 ImageIndex = 27
OnExecute = actFileCloseExecute OnExecute = actFileCloseExecute
OnUpdate = updateDocumentBasedAction
ShortCut = 16471 ShortCut = 16471
end end
object actFileOpenContFold: TAction object actFileOpenContFold: TAction
@ -2318,18 +2349,21 @@ object CEMainForm: TCEMainForm
Caption = 'View in mini explorer' Caption = 'View in mini explorer'
ImageIndex = 29 ImageIndex = 29
OnExecute = actFileOpenContFoldExecute OnExecute = actFileOpenContFoldExecute
OnUpdate = updateDocumentBasedAction
end end
object actFileHtmlExport: TAction object actFileHtmlExport: TAction
Category = 'File' Category = 'File'
Caption = 'Export to html...' Caption = 'Export to html...'
ImageIndex = 33 ImageIndex = 33
OnExecute = actFileHtmlExportExecute OnExecute = actFileHtmlExportExecute
OnUpdate = updateDocumentBasedAction
end end
object actFileUnittest: TAction object actFileUnittest: TAction
Category = 'File' Category = 'File'
Caption = 'Run file unittests' Caption = 'Run file unittests'
ImageIndex = 22 ImageIndex = 22
OnExecute = actFileUnittestExecute OnExecute = actFileUnittestExecute
OnUpdate = updateDocumentBasedAction
end end
end end
object imgList: TImageList object imgList: TImageList

View File

@ -135,6 +135,8 @@ type
MenuItem7: TMenuItem; MenuItem7: TMenuItem;
MenuItem8: TMenuItem; MenuItem8: TMenuItem;
MenuItem9: TMenuItem; MenuItem9: TMenuItem;
procedure updateDocumentBasedAction(sender: TObject);
procedure updateProjectBasedAction(sender: TObject);
procedure actFileCompileAndRunOutExecute(Sender: TObject); procedure actFileCompileAndRunOutExecute(Sender: TObject);
procedure actEdFindExecute(Sender: TObject); procedure actEdFindExecute(Sender: TObject);
procedure actEdFindNextExecute(Sender: TObject); procedure actEdFindNextExecute(Sender: TObject);
@ -706,95 +708,28 @@ begin
SaveDocking; SaveDocking;
end; end;
procedure TCEMainForm.ActionsUpdate(AAction: TBasicAction; var Handled: Boolean); procedure TCEMainForm.updateDocumentBasedAction(sender: TObject);
var
hasEd: boolean;
hasProj: boolean;
begin begin
Handled := true; TAction(sender).Enabled := fDoc <> nil;
{$IFDEF LINUX} end;
// TODO-cbugfix-linux: AV when closing document, current workaround may have other side effects.
// fixes some issues with property inspectors. procedure TCEMainForm.updateProjectBasedAction(sender: TObject);
// option editor: IdleTimer seems to be used to refresh values after editing (e.g TColorPropertyEditor) begin
If not Focused then exit; TAction(sender).Enabled := fProject <> nil;
// fixes the error raised when the update is called after docClosing () end;
// looks like a syncro error, needs more investigation.
Application.DisableIdleHandler; procedure TCEMainForm.ActionsUpdate(AAction: TBasicAction; var Handled: Boolean);
{$ENDIF} begin
// TODO-cTest: linux, confirm close doc AV & TCOlorPropertyEditor conv err are fixed
Handled := false;
if fUpdateCount > 0 then exit; if fUpdateCount > 0 then exit;
Inc(fUpdateCount); Inc(fUpdateCount);
clearActProviderEntries;
collectedActProviderEntries;
try try
HasEd := fDoc <> nil; clearActProviderEntries;
if hasEd then collectedActProviderEntries;
begin if (AAction <> nil ) then
actEdCopy.Enabled := fDoc.SelAvail and fDoc.Focused; if not AAction.Update then
actEdCut.Enabled := fDoc.SelAvail and fDoc.Focused; TAction(AAction).enabled := true;
actEdPaste.Enabled := fDoc.CanPaste and fDoc.Focused;
actEdUndo.Enabled := fDoc.CanUndo;
actEdRedo.Enabled := fDoc.CanRedo;
//
actFileCompAndRun.Enabled := fDoc.isDSource;
actFileCompAndRunWithArgs.Enabled := fDoc.isDSource;
actFileCompileAndRunOut.Enabled := fDoc.isDSource;
actFileUnittest.Enabled := fDoc.isDSource;
//
actEdMacPlay.Enabled := true;
actEdMacStartStop.Enabled := true;
actEdIndent.Enabled := true;
actEdUnIndent.Enabled := true;
//
actFileSave.Enabled := true;
actFileSaveAs.Enabled := true;
actFileClose.Enabled := true;
actFileSaveAll.Enabled := true;
actFileOpenContFold.Enabled := true;
actFileHtmlExport.Enabled := true;
end
else begin
actEdCopy.Enabled := false;
actEdCut.Enabled := false ;
actEdPaste.Enabled := false;
actEdUndo.Enabled := false;
actEdRedo.Enabled := false;
actEdMacPlay.Enabled := false;
actEdMacStartStop.Enabled := false;
actEdIndent.Enabled := false;
actEdUnIndent.Enabled := false;
//
actFileCompAndRun.Enabled := false;
actFileCompAndRunWithArgs.Enabled := false;
actFileCompileAndRunOut.Enabled := false;
actFileUnittest.Enabled := false;
actFileSave.Enabled := false;
actFileSaveAs.Enabled := false;
actFileClose.Enabled := false;
actFileSaveAll.Enabled := false;
actFileOpenContFold.Enabled := false;
actFileHtmlExport.Enabled := false;
end;
hasProj := fProject <> nil;
actProjSave.Enabled := hasProj;
actProjSaveAs.Enabled := hasProj;
actProjOpts.Enabled := hasProj;
actProjClose.Enabled := hasProj;
actProjCompile.Enabled := hasProj;
actProjCompileAndRun.Enabled := hasProj;
actProjCompAndRunWithArgs.Enabled := hasProj;
actProjOptView.Enabled := hasProj;
actProjOpenContFold.Enabled := hasProj;
if hasProj then
begin
actProjSource.Enabled := fileExists(fProject.Filename);
actProjRun.Enabled := fProject.canBeRun;
actProjRunWithArgs.Enabled := fProject.canBeRun;
end;
actFileAddToProj.Enabled := hasEd and hasProj;
//
updateMainMenuProviders; updateMainMenuProviders;
finally finally
Dec(fUpdateCount); Dec(fUpdateCount);