mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-02 15:59:39 +01:00
implemented IDE start protocol and avoiding loading a crashing project twice from Andrew Haines
git-svn-id: trunk@7005 -
This commit is contained in:
parent
e66b2fa73c
commit
f1efae7c04
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -783,6 +783,7 @@ ide/helpoptions.pas svneol=native#text/pascal
|
|||||||
ide/idedefs.pas svneol=native#text/pascal
|
ide/idedefs.pas svneol=native#text/pascal
|
||||||
ide/ideoptiondefs.pas svneol=native#text/pascal
|
ide/ideoptiondefs.pas svneol=native#text/pascal
|
||||||
ide/ideprocs.pp svneol=native#text/pascal
|
ide/ideprocs.pp svneol=native#text/pascal
|
||||||
|
ide/ideprotocol.pas svneol=native#text/pascal
|
||||||
ide/imexportcompileropts.lfm svneol=native#text/plain
|
ide/imexportcompileropts.lfm svneol=native#text/plain
|
||||||
ide/imexportcompileropts.lrs svneol=native#text/pascal
|
ide/imexportcompileropts.lrs svneol=native#text/pascal
|
||||||
ide/imexportcompileropts.pas svneol=native#text/pascal
|
ide/imexportcompileropts.pas svneol=native#text/pascal
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
{ This file was automatically created by Lazarus. Do not edit!
|
{ This file was automatically created by Lazarus. Do not edit!
|
||||||
This source is only used to compile and install
|
This source is only used to compile and install the package.
|
||||||
the package Printer4Lazarus 0.0.0.1.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unit Printer4Lazarus;
|
unit Printer4Lazarus;
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
{ This file was automatically created by Lazarus. Do not edit!
|
{ This file was automatically created by Lazarus. Do not edit!
|
||||||
This source is only used to compile and install
|
This source is only used to compile and install the package.
|
||||||
the package RunTimeTypeInfoControls 0.1.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unit RunTimeTypeInfoControls;
|
unit RunTimeTypeInfoControls;
|
||||||
|
|||||||
@ -1207,41 +1207,30 @@ begin
|
|||||||
,FAutoSaveIntervalInSecs,600);
|
,FAutoSaveIntervalInSecs,600);
|
||||||
XMLConfig.SetDeleteValue(Path+'AutoSave/LastSavedProjectFile'
|
XMLConfig.SetDeleteValue(Path+'AutoSave/LastSavedProjectFile'
|
||||||
,FLastSavedProjectFile,'');
|
,FLastSavedProjectFile,'');
|
||||||
XMLConfig.SetDeleteValue(
|
XMLConfig.SetDeleteValue(Path+'AutoSave/OpenLastProjectAtStart',
|
||||||
Path+'AutoSave/OpenLastProjectAtStart',
|
|
||||||
FOpenLastProjectAtStart,true);
|
FOpenLastProjectAtStart,true);
|
||||||
|
|
||||||
// windows
|
// windows
|
||||||
FIDEWindowLayoutList.SaveToXMLConfig(XMLConfig,
|
FIDEWindowLayoutList.SaveToXMLConfig(XMLConfig,Path+'Desktop/');
|
||||||
Path+'Desktop/');
|
FIDEDialogLayoutList.SaveToXMLConfig(XMLConfig,Path+'Desktop/Dialogs');
|
||||||
FIDEDialogLayoutList.SaveToXMLConfig(XMLConfig,
|
XMLConfig.SetDeleteValue(Path+'Desktop/MinimizeAllOnMinimizeMain/Value',
|
||||||
Path+'Desktop/Dialogs');
|
|
||||||
XMLConfig.SetDeleteValue(
|
|
||||||
Path+'Desktop/MinimizeAllOnMinimizeMain/Value',
|
|
||||||
FMinimizeAllOnMinimizeMain,true);
|
FMinimizeAllOnMinimizeMain,true);
|
||||||
XMLConfig.SetDeleteValue(
|
XMLConfig.SetDeleteValue(Path+'Desktop/HideIDEOnRun/Value',FHideIDEOnRun,
|
||||||
Path+'Desktop/HideIDEOnRun/Value',FHideIDEOnRun,false);
|
false);
|
||||||
|
|
||||||
// form editor
|
// form editor
|
||||||
XMLConfig.SetDeleteValue(
|
XMLConfig.SetDeleteValue(Path+'FormEditor/ShowGrid',FShowGrid,true);
|
||||||
Path+'FormEditor/ShowGrid',FShowGrid,true);
|
XMLConfig.SetDeleteValue(Path+'FormEditor/GridColor',FGridColor,clBlack);
|
||||||
XMLConfig.SetDeleteValue(
|
XMLConfig.SetDeleteValue(Path+'FormEditor/SnapToGrid',FSnapToGrid,true);
|
||||||
Path+'FormEditor/GridColor',FGridColor,clBlack);
|
XMLConfig.SetDeleteValue(Path+'FormEditor/GridSizeX',FGridSizeX,8);
|
||||||
XMLConfig.SetDeleteValue(
|
XMLConfig.SetDeleteValue(Path+'FormEditor/GridSizeY',FGridSizeY,8);
|
||||||
Path+'FormEditor/SnapToGrid',FSnapToGrid,true);
|
XMLConfig.SetDeleteValue(Path+'FormEditor/ShowGuideLines',FShowGuideLines,
|
||||||
XMLConfig.SetDeleteValue(
|
true);
|
||||||
Path+'FormEditor/GridSizeX',FGridSizeX,8);
|
XMLConfig.SetDeleteValue(Path+'FormEditor/SnapToGuideLines',
|
||||||
XMLConfig.SetDeleteValue(
|
FSnapToGuideLines,true);
|
||||||
Path+'FormEditor/GridSizeY',FGridSizeY,8);
|
XMLConfig.SetDeleteValue(Path+'FormEditor/GuideLineColorLeftTop',
|
||||||
XMLConfig.SetDeleteValue(
|
|
||||||
Path+'FormEditor/ShowGuideLines',FShowGuideLines,true);
|
|
||||||
XMLConfig.SetDeleteValue(
|
|
||||||
Path+'FormEditor/SnapToGuideLines',FSnapToGuideLines,true);
|
|
||||||
XMLConfig.SetDeleteValue(
|
|
||||||
Path+'FormEditor/GuideLineColorLeftTop',
|
|
||||||
FGuideLineColorLeftTop,clGreen);
|
FGuideLineColorLeftTop,clGreen);
|
||||||
XMLConfig.SetDeleteValue(
|
XMLConfig.SetDeleteValue(Path+'FormEditor/GuideLineColorRightBottom',
|
||||||
Path+'FormEditor/GuideLineColorRightBottom',
|
|
||||||
FGuideLineColorRightBottom,clBlue);
|
FGuideLineColorRightBottom,clBlue);
|
||||||
XMLConfig.SetDeleteValue(Path+'FormEditor/ShowComponentCaptions',
|
XMLConfig.SetDeleteValue(Path+'FormEditor/ShowComponentCaptions',
|
||||||
FShowComponentCaptions,true);
|
FShowComponentCaptions,true);
|
||||||
|
|||||||
137
ide/ideprotocol.pas
Normal file
137
ide/ideprotocol.pas
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
{
|
||||||
|
***************************************************************************
|
||||||
|
* *
|
||||||
|
* This source is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This code is distributed in the hope that it will be useful, but *
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||||
|
* General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* A copy of the GNU General Public License is available on the World *
|
||||||
|
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
|
||||||
|
* obtain it by writing to the Free Software Foundation, *
|
||||||
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
|
* *
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
Author: Mattias Gaertner
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
The IDE keeps book about loading projects and forms. When an error occurs,
|
||||||
|
that kills the IDE, it will not open it automatically again the next time.
|
||||||
|
|
||||||
|
}
|
||||||
|
unit IDEProtocol;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils, LCLProc, LazConf, ConfigStorage;
|
||||||
|
|
||||||
|
const
|
||||||
|
IDEProtocolOptsVersion: integer = 1;
|
||||||
|
IDEProtocolFilename = 'protocol.xml';
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TIDEProtocol }
|
||||||
|
|
||||||
|
TIDEProtocol = class
|
||||||
|
private
|
||||||
|
FFilename: string;
|
||||||
|
FLastProjectLoadingCrashed: boolean;
|
||||||
|
public
|
||||||
|
constructor Create;
|
||||||
|
destructor Destroy; override;
|
||||||
|
procedure Load;
|
||||||
|
procedure Save;
|
||||||
|
procedure LoadFromConfig(Config: TConfigStorage; const Path: string);
|
||||||
|
procedure SaveToConfig(Config: TConfigStorage; const Path: string);
|
||||||
|
public
|
||||||
|
property Filename: string read FFilename write FFilename;
|
||||||
|
property LastProjectLoadingCrashed: boolean read FLastProjectLoadingCrashed
|
||||||
|
write FLastProjectLoadingCrashed;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
IDEProtocolOpts: TIDEProtocol;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{ TIDEProtocol }
|
||||||
|
|
||||||
|
constructor TIDEProtocol.Create;
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TIDEProtocol.Destroy;
|
||||||
|
begin
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIDEProtocol.Load;
|
||||||
|
var
|
||||||
|
Config: TConfigStorage;
|
||||||
|
begin
|
||||||
|
if Filename='' then
|
||||||
|
Filename:=SetDirSeparators(GetPrimaryConfigPath+'/'+IDEProtocolFilename);
|
||||||
|
try
|
||||||
|
Config:=DefaultConfigClass.Create(Filename,true);
|
||||||
|
try
|
||||||
|
LoadFromConfig(Config,'Protocol/');
|
||||||
|
finally
|
||||||
|
Config.Free;
|
||||||
|
end;
|
||||||
|
except
|
||||||
|
on E: Exception do begin
|
||||||
|
// ToDo
|
||||||
|
DebugLn('[TIDEProtocol.Load] error reading "',Filename,'": ',E.Message);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIDEProtocol.Save;
|
||||||
|
var
|
||||||
|
Config: TConfigStorage;
|
||||||
|
begin
|
||||||
|
if Filename='' then
|
||||||
|
Filename:=SetDirSeparators(GetPrimaryConfigPath+'/'+IDEProtocolFilename);
|
||||||
|
try
|
||||||
|
Config:=DefaultConfigClass.Create(Filename,false);
|
||||||
|
try
|
||||||
|
SaveToConfig(Config,'Protocol/');
|
||||||
|
Config.WriteToDisk;
|
||||||
|
finally
|
||||||
|
Config.Free;
|
||||||
|
end;
|
||||||
|
except
|
||||||
|
on E: Exception do begin
|
||||||
|
// ToDo
|
||||||
|
DebugLn('[TIDEProtocol.Save] error writing "',Filename,'": ',E.Message);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIDEProtocol.LoadFromConfig(Config: TConfigStorage; const Path: string
|
||||||
|
);
|
||||||
|
begin
|
||||||
|
FLastProjectLoadingCrashed:=
|
||||||
|
Config.GetValue(Path+'LastProjectLoading/Failed',false);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TIDEProtocol.SaveToConfig(Config: TConfigStorage; const Path: string
|
||||||
|
);
|
||||||
|
begin
|
||||||
|
Config.SetValue(Path+'Version',IDEProtocolOptsVersion);
|
||||||
|
Config.SetDeleteValue(Path+'LastProjectLoading/Failed',
|
||||||
|
FLastProjectLoadingCrashed,false);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
||||||
44
ide/main.pp
44
ide/main.pp
@ -73,6 +73,8 @@ uses
|
|||||||
NewItemIntf, PackageIntf, ProjectIntf, LazIDEIntf,
|
NewItemIntf, PackageIntf, ProjectIntf, LazIDEIntf,
|
||||||
// synedit
|
// synedit
|
||||||
SynEditKeyCmds,
|
SynEditKeyCmds,
|
||||||
|
// protocol
|
||||||
|
IDEProtocol,
|
||||||
// compile
|
// compile
|
||||||
Compiler, CompilerOptions, CompilerOptionsDlg, CheckCompilerOpts,
|
Compiler, CompilerOptions, CompilerOptionsDlg, CheckCompilerOpts,
|
||||||
ImExportCompilerOpts,
|
ImExportCompilerOpts,
|
||||||
@ -454,6 +456,7 @@ type
|
|||||||
procedure AddRecentProjectFileToEnvironment(const AFilename: string);
|
procedure AddRecentProjectFileToEnvironment(const AFilename: string);
|
||||||
|
|
||||||
// methods for start
|
// methods for start
|
||||||
|
procedure StartProtocol;
|
||||||
procedure LoadGlobalOptions;
|
procedure LoadGlobalOptions;
|
||||||
procedure SetupMainMenu; override;
|
procedure SetupMainMenu; override;
|
||||||
procedure SetupStandardProjectTypes;
|
procedure SetupStandardProjectTypes;
|
||||||
@ -954,6 +957,7 @@ begin
|
|||||||
|
|
||||||
// load options
|
// load options
|
||||||
CreatePrimaryConfigPath;
|
CreatePrimaryConfigPath;
|
||||||
|
StartProtocol;
|
||||||
LoadGlobalOptions;
|
LoadGlobalOptions;
|
||||||
|
|
||||||
// set the IDE mode to none (= editing mode)
|
// set the IDE mode to none (= editing mode)
|
||||||
@ -1082,6 +1086,8 @@ begin
|
|||||||
FreeThenNil(SourceNotebook);
|
FreeThenNil(SourceNotebook);
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.Destroy C ');{$ENDIF}
|
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.Destroy C ');{$ENDIF}
|
||||||
|
|
||||||
|
FreeThenNil(IDEProtocolOpts);
|
||||||
DebugLn('[TMainIDE.Destroy] END');
|
DebugLn('[TMainIDE.Destroy] END');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1502,6 +1508,14 @@ procedure TMainIDE.SetupStartProject;
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function AskIfLoadLastFailingProject: boolean;
|
||||||
|
begin
|
||||||
|
Result:=MessageDlg('An error occured at last startup while loading '
|
||||||
|
+EnvironmentOptions.LastSavedProjectFile+ '!'#13
|
||||||
|
+#13
|
||||||
|
+'Load this project again?', mtWarning, [mbYes,mbNo],0)=mrYes;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
ProjectLoaded: Boolean;
|
ProjectLoaded: Boolean;
|
||||||
AProjectFilename: String;
|
AProjectFilename: String;
|
||||||
@ -1511,7 +1525,7 @@ var
|
|||||||
AFilename: String;
|
AFilename: String;
|
||||||
begin
|
begin
|
||||||
{$IFDEF IDE_DEBUG}
|
{$IFDEF IDE_DEBUG}
|
||||||
writeln('TMainIDE.Create A ***********');
|
writeln('TMainIDE.SetupStartProject A ***********');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.SetupStartProject A');{$ENDIF}
|
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.SetupStartProject A');{$ENDIF}
|
||||||
// load command line project or last project or create a new project
|
// load command line project or last project or create a new project
|
||||||
@ -1531,13 +1545,24 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// try loading last project
|
// try loading last project if lazarus didn't fail last time
|
||||||
if (not ProjectLoaded)
|
if (not ProjectLoaded)
|
||||||
and (not SkipAutoLoadingLastProject)
|
and (not SkipAutoLoadingLastProject)
|
||||||
and (EnvironmentOptions.OpenLastProjectAtStart)
|
and (EnvironmentOptions.OpenLastProjectAtStart)
|
||||||
and (FileExists(EnvironmentOptions.LastSavedProjectFile)) then begin
|
and (FileExists(EnvironmentOptions.LastSavedProjectFile)) then begin
|
||||||
ProjectLoaded:=
|
if (not IDEProtocolOpts.LastProjectLoadingCrashed)
|
||||||
(DoOpenProjectFile(EnvironmentOptions.LastSavedProjectFile,[])=mrOk);
|
or AskIfLoadLastFailingProject then begin
|
||||||
|
// protocol that the IDE is trying to load the last project and did not
|
||||||
|
// yet succeed
|
||||||
|
IDEProtocolOpts.LastProjectLoadingCrashed := True;
|
||||||
|
IDEProtocolOpts.Save;
|
||||||
|
// try loading the project
|
||||||
|
ProjectLoaded:=
|
||||||
|
(DoOpenProjectFile(EnvironmentOptions.LastSavedProjectFile,[])=mrOk);
|
||||||
|
// protocol that the IDE was able to open the project without crashing
|
||||||
|
IDEProtocolOpts.LastProjectLoadingCrashed := false;
|
||||||
|
IDEProtocolOpts.Save;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.SetupStartProject B');{$ENDIF}
|
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.SetupStartProject B');{$ENDIF}
|
||||||
|
|
||||||
@ -5705,6 +5730,7 @@ begin
|
|||||||
Result:=Project1.WriteProject([],'');
|
Result:=Project1.WriteProject([],'');
|
||||||
if Result=mrAbort then exit;
|
if Result=mrAbort then exit;
|
||||||
EnvironmentOptions.LastSavedProjectFile:=Project1.ProjectInfoFile;
|
EnvironmentOptions.LastSavedProjectFile:=Project1.ProjectInfoFile;
|
||||||
|
IDEProtocolOpts.LastProjectLoadingCrashed := False;
|
||||||
AddRecentProjectFileToEnvironment(Project1.ProjectInfoFile);
|
AddRecentProjectFileToEnvironment(Project1.ProjectInfoFile);
|
||||||
SaveIncludeLinks;
|
SaveIncludeLinks;
|
||||||
UpdateCaption;
|
UpdateCaption;
|
||||||
@ -5971,6 +5997,7 @@ begin
|
|||||||
Project1.Modified:=false;
|
Project1.Modified:=false;
|
||||||
|
|
||||||
IncreaseCompilerParseStamp;
|
IncreaseCompilerParseStamp;
|
||||||
|
IDEProtocolOpts.LastProjectLoadingCrashed := False;
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
{$IFDEF IDE_VERBOSE}
|
{$IFDEF IDE_VERBOSE}
|
||||||
debugln('TMainIDE.DoOpenProjectFile end CodeToolBoss.ConsistencyCheck=',CodeToolBoss.ConsistencyCheck);
|
debugln('TMainIDE.DoOpenProjectFile end CodeToolBoss.ConsistencyCheck=',CodeToolBoss.ConsistencyCheck);
|
||||||
@ -11465,6 +11492,12 @@ begin
|
|||||||
SaveEnvironment;
|
SaveEnvironment;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainIDE.StartProtocol;
|
||||||
|
begin
|
||||||
|
IDEProtocolOpts:=TIDEProtocol.Create;
|
||||||
|
IDEProtocolOpts.Load;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.mnuSearchFindBlockOtherEnd(Sender: TObject);
|
procedure TMainIDE.mnuSearchFindBlockOtherEnd(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
DoGoToPascalBlockOtherEnd;
|
DoGoToPascalBlockOtherEnd;
|
||||||
@ -11493,6 +11526,9 @@ end.
|
|||||||
|
|
||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.860 2005/03/21 11:12:25 mattias
|
||||||
|
implemented IDE start protocol and avoiding loading a crashing project twice from Andrew Haines
|
||||||
|
|
||||||
Revision 1.859 2005/03/16 12:03:40 mattias
|
Revision 1.859 2005/03/16 12:03:40 mattias
|
||||||
added check for UpdateCaption if MainIDEBar is already destroyed
|
added check for UpdateCaption if MainIDEBar is already destroyed
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user