mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-11 13:19:21 +02:00
IDE: option auto open designers nd project open: restore last opened designers, bug #16952
git-svn-id: trunk@26700 -
This commit is contained in:
parent
aa11530e5a
commit
f41306c655
30
ide/main.pp
30
ide/main.pp
@ -1023,7 +1023,8 @@ type
|
||||
procedure DoShowSourceOfActiveDesignerForm;
|
||||
procedure SetDesigning(AComponent: TComponent; Value: Boolean);
|
||||
procedure SetDesignInstance(AComponent: TComponent; Value: Boolean);
|
||||
procedure CreateDesignerForComponent(AComponent: TComponent);
|
||||
procedure CreateDesignerForComponent(AnUnitInfo: TUnitInfo;
|
||||
AComponent: TComponent);
|
||||
procedure InvalidateAllDesignerForms;
|
||||
procedure UpdateIDEComponentPalette;
|
||||
procedure ShowDesignerForm(AForm: TCustomForm);
|
||||
@ -3259,7 +3260,8 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.CreateDesignerForComponent(AComponent: TComponent);
|
||||
procedure TMainIDE.CreateDesignerForComponent(AnUnitInfo: TUnitInfo;
|
||||
AComponent: TComponent);
|
||||
var
|
||||
DesignerForm: TCustomForm;
|
||||
begin
|
||||
@ -3306,6 +3308,8 @@ begin
|
||||
ShowEditorHints:=EnvironmentOptions.ShowEditorHints;
|
||||
ShowComponentCaptions := EnvironmentOptions.ShowComponentCaptions;
|
||||
end;
|
||||
if AnUnitInfo<>nil then
|
||||
AnUnitInfo.LoadedDesigner:=true;
|
||||
end;
|
||||
|
||||
{-------------------------------------------------------------------------------
|
||||
@ -4693,7 +4697,7 @@ begin
|
||||
and (csSetCaption in TControl(NewComponent).ControlStyle) then
|
||||
TControl(NewComponent).Caption:=NewComponent.Name;
|
||||
NewUnitInfo.Component := NewComponent;
|
||||
CreateDesignerForComponent(NewComponent);
|
||||
CreateDesignerForComponent(NewUnitInfo,NewComponent);
|
||||
|
||||
NewUnitInfo.ComponentName:=NewComponent.Name;
|
||||
NewUnitInfo.ComponentResourceName:=NewUnitInfo.ComponentName;
|
||||
@ -6158,7 +6162,7 @@ begin
|
||||
DesignerForm := nil;
|
||||
if not (ofLoadHiddenResource in OpenFlags) then
|
||||
begin
|
||||
CreateDesignerForComponent(NewComponent);
|
||||
CreateDesignerForComponent(AnUnitInfo,NewComponent);
|
||||
DesignerForm := FormEditor1.GetDesignerForm(NewComponent);
|
||||
end;
|
||||
|
||||
@ -6967,6 +6971,7 @@ begin
|
||||
{$IFDEF VerboseIDEMultiForm}
|
||||
DebugLn(['TMainIDE.CloseUnitComponent hiding component and freeing designer: ',AnUnitInfo.Filename,' ',DbgSName(AnUnitInfo.Component)]);
|
||||
{$ENDIF}
|
||||
AnUnitInfo.LoadedDesigner:=false;
|
||||
OldDesigner.FreeDesigner(false);
|
||||
end else begin
|
||||
// free designer and design form
|
||||
@ -6974,6 +6979,7 @@ begin
|
||||
DebugLn(['TMainIDE.CloseUnitComponent freeing component and designer: ',AnUnitInfo.Filename,' ',DbgSName(AnUnitInfo.Component)]);
|
||||
{$ENDIF}
|
||||
try
|
||||
AnUnitInfo.LoadedDesigner:=false;
|
||||
OldDesigner.FreeDesigner(true);
|
||||
finally
|
||||
AnUnitInfo.Component:=nil;
|
||||
@ -8381,14 +8387,15 @@ var
|
||||
if FilenameIsPascalUnit(AFilename) then begin
|
||||
// this could be a unit with a form
|
||||
//debugln('TMainIDE.DoOpenEditorFile ',AFilename,' ',OpenFlagsToString(Flags));
|
||||
if ([ofDoNotLoadResource,ofProjectLoading]*Flags=[])
|
||||
if ([ofDoNotLoadResource]*Flags=[])
|
||||
and ( (ofDoLoadResource in Flags)
|
||||
or ((not Project1.AutoOpenDesignerFormsDisabled)
|
||||
and (EnvironmentOptions.AutoCreateFormsOnOpen
|
||||
or (NewUnitInfo.Component<>nil))))
|
||||
or ((ofProjectLoading in Flags)
|
||||
and NewUnitInfo.LoadedDesigner
|
||||
and (not Project1.AutoOpenDesignerFormsDisabled)
|
||||
and EnvironmentOptions.AutoCreateFormsOnOpen))
|
||||
then begin
|
||||
// -> try to (re)load the lfm file
|
||||
//debugln('TMainIDE.DoOpenEditorFile Loading LFM for ',NewUnitInfo.Filename);
|
||||
//debugln(['TMainIDE.DoOpenEditorFile Loading LFM for ',NewUnitInfo.Filename,' LoadedDesigner=',NewUnitInfo.LoadedDesigner]);
|
||||
CloseFlags:=[cfSaveDependencies];
|
||||
if ofRevert in Flags then
|
||||
Include(CloseFlags,cfCloseDependencies);
|
||||
@ -8409,8 +8416,11 @@ var
|
||||
if Result<>mrOk then begin
|
||||
DebugLn(['OpenResource CloseUnitComponent failed']);
|
||||
end;
|
||||
end else
|
||||
end else begin
|
||||
Result:=mrOk;
|
||||
end;
|
||||
if NewUnitInfo.Component=nil then
|
||||
NewUnitInfo.LoadedDesigner:=false;
|
||||
end;
|
||||
|
||||
begin
|
||||
|
@ -272,7 +272,8 @@ type
|
||||
fHasResources: boolean; // source has resource file
|
||||
FIgnoreFileDateOnDiskValid: boolean;
|
||||
FIgnoreFileDateOnDisk: longint;
|
||||
fLoaded: Boolean; // loaded in the source editor
|
||||
fLoaded: Boolean; // loaded in the source editor, needed to restore open files
|
||||
fLoadedDesigner: Boolean; // has a visible designer, needed to restore open designers
|
||||
FLoadingComponent: boolean;
|
||||
fModified: boolean;
|
||||
fNext, fPrev: array[TUnitInfoList] of TUnitInfo;
|
||||
@ -315,6 +316,7 @@ type
|
||||
procedure SetFileReadOnly(const AValue: Boolean);
|
||||
procedure SetComponent(const AValue: TComponent);
|
||||
procedure SetLoaded(const AValue: Boolean);
|
||||
procedure SetLoadedDesigner(const AValue: Boolean);
|
||||
procedure SetModified(const AValue: boolean);
|
||||
procedure SetProject(const AValue: TProject);
|
||||
procedure SetRunFileIfActive(const AValue: boolean);
|
||||
@ -361,7 +363,8 @@ type
|
||||
function CreateUnitName: string;
|
||||
procedure ImproveUnitNameCache(const NewUnitName: string);
|
||||
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
||||
Merge, IgnoreIsPartOfProject: boolean);
|
||||
Merge, IgnoreIsPartOfProject: boolean;
|
||||
FileVersion: integer);
|
||||
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
||||
SaveData, SaveSession: boolean;
|
||||
UsePathDelim: TPathDelimSwitch);
|
||||
@ -443,6 +446,7 @@ type
|
||||
property Flags: TUnitInfoFlags read FFlags write FFlags;
|
||||
property HasResources: boolean read GetHasResources write fHasResources;
|
||||
property Loaded: Boolean read fLoaded write SetLoaded;
|
||||
property LoadedDesigner: Boolean read fLoadedDesigner write SetLoadedDesigner;
|
||||
property LoadingComponent: boolean read FLoadingComponent write FLoadingComponent;
|
||||
property Modified: boolean read GetModified write SetModified;// not Session data
|
||||
property SessionModified: boolean read FSessionModified write SetSessionModified;
|
||||
@ -1040,7 +1044,7 @@ function dbgs(Flags: TUnitInfoFlags): string; overload;
|
||||
implementation
|
||||
|
||||
const
|
||||
ProjectInfoFileVersion = 7;
|
||||
ProjectInfoFileVersion = 8;
|
||||
|
||||
procedure AddCompileReasonsDiff(Tool: TCompilerDiffTool;
|
||||
const PropertyName: string; const Old, New: TCompileReasons);
|
||||
@ -1538,6 +1542,7 @@ begin
|
||||
fUserReadOnly := false;
|
||||
if fSource<>nil then fSource.Clear;
|
||||
Loaded := false;
|
||||
LoadedDesigner := false;
|
||||
ClearComponentDependencies;
|
||||
end;
|
||||
|
||||
@ -1638,6 +1643,7 @@ begin
|
||||
end;
|
||||
FBookmarks.SaveToXMLConfig(XMLConfig,Path+'Bookmarks/');
|
||||
XMLConfig.SetDeleteValue(Path+'Loaded/Value',fLoaded,false);
|
||||
XMLConfig.SetDeleteValue(Path+'LoadedDesigner/Value',fLoadedDesigner,false);
|
||||
XMLConfig.SetDeleteValue(Path+'ReadOnly/Value',fUserReadOnly,false);
|
||||
XMLConfig.SetDeleteValue(Path+'BuildFileIfActive/Value',
|
||||
FBuildFileIfActive,false);
|
||||
@ -1654,8 +1660,9 @@ end;
|
||||
{------------------------------------------------------------------------------
|
||||
TUnitInfo LoadFromXMLConfig
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TUnitInfo.LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string;
|
||||
Merge, IgnoreIsPartOfProject: boolean);
|
||||
procedure TUnitInfo.LoadFromXMLConfig(XMLConfig: TXMLConfig;
|
||||
const Path: string; Merge, IgnoreIsPartOfProject: boolean;
|
||||
FileVersion: integer);
|
||||
var
|
||||
AFilename: string;
|
||||
c, i: Integer;
|
||||
@ -1700,6 +1707,10 @@ begin
|
||||
FEditorInfoList.NewEditorInfo.LoadFromXMLConfig(XMLConfig, Path + 'ExtraEditor'+IntToStr(i)+'/');
|
||||
|
||||
Loaded:=XMLConfig.GetValue(Path+'Loaded/Value',false);
|
||||
if Loaded then
|
||||
LoadedDesigner:=XMLConfig.GetValue(Path+'LoadedDesigner/Value',FileVersion<8)
|
||||
else
|
||||
LoadedDesigner:=false;
|
||||
fUserReadOnly:=XMLConfig.GetValue(Path+'ReadOnly/Value',false);
|
||||
FBuildFileIfActive:=XMLConfig.GetValue(Path+'BuildFileIfActive/Value',
|
||||
false);
|
||||
@ -2366,7 +2377,7 @@ end;
|
||||
procedure TUnitInfo.SetLoaded(const AValue: Boolean);
|
||||
|
||||
Loaded is a flag, that is set, when a unit has finished loading into the
|
||||
editor. It is saved to the project info file and a loaded unit will be
|
||||
editor. It is saved to the project session file and a loaded unit will be
|
||||
reloaded, when the project is opened.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TUnitInfo.SetLoaded(const AValue: Boolean);
|
||||
@ -2381,6 +2392,20 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{-------------------------------------------------------------------------------
|
||||
procedure TUnitInfo.SetLoadedDesigner(const AValue: Boolean);
|
||||
|
||||
LoadedDesigner is a flag, that is set, when a visible designer form has
|
||||
finished opening. It is saved to the project session file and a designer
|
||||
is restored, when the project is opened and the IDE form editor option
|
||||
auto open designer forms is enabled.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TUnitInfo.SetLoadedDesigner(const AValue: Boolean);
|
||||
begin
|
||||
if fLoadedDesigner=AValue then exit;
|
||||
fLoadedDesigner:=AValue;
|
||||
end;
|
||||
|
||||
procedure TUnitInfo.SetModified(const AValue: boolean);
|
||||
begin
|
||||
if fModified=AValue then exit;
|
||||
@ -2974,7 +2999,7 @@ var
|
||||
MergeUnitInfo:=false;
|
||||
end;
|
||||
|
||||
NewUnitInfo.LoadFromXMLConfig(xmlconfig,SubPath,MergeUnitInfo,Merge);
|
||||
NewUnitInfo.LoadFromXMLConfig(xmlconfig,SubPath,MergeUnitInfo,Merge,FileVersion);
|
||||
if i=NewMainUnitID then begin
|
||||
MainUnitID:=IndexOf(NewUnitInfo);
|
||||
NewMainUnitID:=-1;
|
||||
@ -3624,7 +3649,7 @@ function TProject.NewUniqueComponentName(const AComponentPrefix: string
|
||||
then exit;
|
||||
end else if (Units[i].ComponentName<>'')
|
||||
and ((Units[i].IsPartOfProject) or (Units[i].Loaded)) then begin
|
||||
if AnsiCompareText(Units[i].ComponentName,AComponentName)=0 then exit;
|
||||
if SysUtils.CompareText(Units[i].ComponentName,AComponentName)=0 then exit;
|
||||
end;
|
||||
end;
|
||||
Result:=false;
|
||||
|
Loading…
Reference in New Issue
Block a user