replace more unit initializers with lazy getters

reminder: use this method when order of init
is not controllable anylomre
This commit is contained in:
Basile Burg 2016-11-07 06:33:44 +01:00
parent 045ec6d42c
commit 9be54eb313
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
4 changed files with 25 additions and 13 deletions

View File

@ -526,6 +526,7 @@
<Filename Value="..\src\ce_compilers.pas"/> <Filename Value="..\src\ce_compilers.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/> <ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
</Unit54> </Unit54>
</Units> </Units>

View File

@ -8,7 +8,7 @@ uses
{$ENDIF}{$ENDIF} {$ENDIF}{$ENDIF}
Interfaces, Forms, lazcontrols, runtimetypeinfocontrols, anchordockpkg, Interfaces, Forms, lazcontrols, runtimetypeinfocontrols, anchordockpkg,
ce_sharedres, ce_observer, ce_libman, ce_symstring, ce_tools, ce_dcd, ce_main, ce_sharedres, ce_observer, ce_libman, ce_symstring, ce_tools, ce_dcd, ce_main,
ce_writableComponent, ce_staticmacro, ce_inspectors, ce_editoroptions, ce_compilers, ce_writableComponent, ce_staticmacro, ce_inspectors, ce_editoroptions,
ce_dockoptions, ce_shortcutseditor, ce_mru, ce_processes, ce_dockoptions, ce_shortcutseditor, ce_mru, ce_processes,
ce_dialogs, ce_dubprojeditor, ce_controls, ce_dfmt, ce_lcldragdrop, ce_dialogs, ce_dubprojeditor, ce_controls, ce_dfmt, ce_lcldragdrop,
ce_stringrange, ce_dlangmaps, ce_projgroup, ce_projutils, ce_d2synpresets, ce_stringrange, ce_dlangmaps, ce_projgroup, ce_projutils, ce_d2synpresets,

View File

@ -31,14 +31,16 @@ type
procedure DragDrop(Sender, Source: TObject; X, Y: Integer); procedure DragDrop(Sender, Source: TObject; X, Y: Integer);
end; end;
var function ddHandler: TDDHandler;
ddHandler: TDDHandler;
implementation implementation
uses uses
ce_observer; ce_observer;
var
fDdHandler: TDDHandler = nil;
constructor TDDHandler.create; constructor TDDHandler.create;
begin begin
EntitiesConnector.addObserver(self); EntitiesConnector.addObserver(self);
@ -152,11 +154,14 @@ begin
else getMultiDocHandler.openDocument(fname); else getMultiDocHandler.openDocument(fname);
end; end;
initialization function ddHandler: TDDHandler;
ddHandler:= TDDHandler.create; begin
if fDdHandler.isNil then
fDdHandler:= TDDHandler.create;
result := fDdHandler;
end;
finalization finalization
ddHandler.free; ddHandler.free;
end. end.

View File

@ -7,7 +7,7 @@ interface
uses uses
Classes, SysUtils, FileUtil, ce_common, ce_writableComponent, LazFileUtils, Classes, SysUtils, FileUtil, ce_common, ce_writableComponent, LazFileUtils,
ghashmap, ghashset, ghashmap, ghashset,
ce_dcd, ce_dialogs, ce_projutils, ce_interfaces, ce_dlang, ce_dastworx, ce_dcd, ce_projutils, ce_interfaces, ce_dlang, ce_dastworx,
ce_compilers; ce_compilers;
type type
@ -135,11 +135,13 @@ type
const const
libFname = 'libraryManager.txt'; libFname = 'libraryManager.txt';
var function LibMan: TLibraryManager;
LibMan: TLibraryManager;
implementation implementation
var
fLibMan: TLibraryManager = nil;
const const
deactivatedMessage = 'Library item "%s" could be detected but it is marked disabled, ' + deactivatedMessage = 'Library item "%s" could be detected but it is marked disabled, ' +
'the compilation will fail.'; 'the compilation will fail.';
@ -663,9 +665,13 @@ begin
end; end;
end; end;
initialization function LibMan: TLibraryManager;
registerClasses([TLibraryManager, TLibraryItem]); begin
LibMan := TLibraryManager.create(nil); if fLibMan.isNil then
fLibMan := TLibraryManager.create(nil);
result := fLibMan;
end;
finalization finalization
LibMan.Free; fLibMan.Free;
end. end.