mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-20 17:14:29 +02: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/ideoptiondefs.pas 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.lrs 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 source is only used to compile and install
|
||||
the package Printer4Lazarus 0.0.0.1.
|
||||
{ This file was automatically created by Lazarus. Do not edit!
|
||||
This source is only used to compile and install the package.
|
||||
}
|
||||
|
||||
unit Printer4Lazarus;
|
||||
|
@ -1,6 +1,5 @@
|
||||
{ This file was automatically created by Lazarus. Do not edit!
|
||||
This source is only used to compile and install
|
||||
the package RunTimeTypeInfoControls 0.1.
|
||||
{ This file was automatically created by Lazarus. Do not edit!
|
||||
This source is only used to compile and install the package.
|
||||
}
|
||||
|
||||
unit RunTimeTypeInfoControls;
|
||||
|
@ -1207,41 +1207,30 @@ begin
|
||||
,FAutoSaveIntervalInSecs,600);
|
||||
XMLConfig.SetDeleteValue(Path+'AutoSave/LastSavedProjectFile'
|
||||
,FLastSavedProjectFile,'');
|
||||
XMLConfig.SetDeleteValue(
|
||||
Path+'AutoSave/OpenLastProjectAtStart',
|
||||
XMLConfig.SetDeleteValue(Path+'AutoSave/OpenLastProjectAtStart',
|
||||
FOpenLastProjectAtStart,true);
|
||||
|
||||
// windows
|
||||
FIDEWindowLayoutList.SaveToXMLConfig(XMLConfig,
|
||||
Path+'Desktop/');
|
||||
FIDEDialogLayoutList.SaveToXMLConfig(XMLConfig,
|
||||
Path+'Desktop/Dialogs');
|
||||
XMLConfig.SetDeleteValue(
|
||||
Path+'Desktop/MinimizeAllOnMinimizeMain/Value',
|
||||
FIDEWindowLayoutList.SaveToXMLConfig(XMLConfig,Path+'Desktop/');
|
||||
FIDEDialogLayoutList.SaveToXMLConfig(XMLConfig,Path+'Desktop/Dialogs');
|
||||
XMLConfig.SetDeleteValue(Path+'Desktop/MinimizeAllOnMinimizeMain/Value',
|
||||
FMinimizeAllOnMinimizeMain,true);
|
||||
XMLConfig.SetDeleteValue(
|
||||
Path+'Desktop/HideIDEOnRun/Value',FHideIDEOnRun,false);
|
||||
XMLConfig.SetDeleteValue(Path+'Desktop/HideIDEOnRun/Value',FHideIDEOnRun,
|
||||
false);
|
||||
|
||||
// form editor
|
||||
XMLConfig.SetDeleteValue(
|
||||
Path+'FormEditor/ShowGrid',FShowGrid,true);
|
||||
XMLConfig.SetDeleteValue(
|
||||
Path+'FormEditor/GridColor',FGridColor,clBlack);
|
||||
XMLConfig.SetDeleteValue(
|
||||
Path+'FormEditor/SnapToGrid',FSnapToGrid,true);
|
||||
XMLConfig.SetDeleteValue(
|
||||
Path+'FormEditor/GridSizeX',FGridSizeX,8);
|
||||
XMLConfig.SetDeleteValue(
|
||||
Path+'FormEditor/GridSizeY',FGridSizeY,8);
|
||||
XMLConfig.SetDeleteValue(
|
||||
Path+'FormEditor/ShowGuideLines',FShowGuideLines,true);
|
||||
XMLConfig.SetDeleteValue(
|
||||
Path+'FormEditor/SnapToGuideLines',FSnapToGuideLines,true);
|
||||
XMLConfig.SetDeleteValue(
|
||||
Path+'FormEditor/GuideLineColorLeftTop',
|
||||
XMLConfig.SetDeleteValue(Path+'FormEditor/ShowGrid',FShowGrid,true);
|
||||
XMLConfig.SetDeleteValue(Path+'FormEditor/GridColor',FGridColor,clBlack);
|
||||
XMLConfig.SetDeleteValue(Path+'FormEditor/SnapToGrid',FSnapToGrid,true);
|
||||
XMLConfig.SetDeleteValue(Path+'FormEditor/GridSizeX',FGridSizeX,8);
|
||||
XMLConfig.SetDeleteValue(Path+'FormEditor/GridSizeY',FGridSizeY,8);
|
||||
XMLConfig.SetDeleteValue(Path+'FormEditor/ShowGuideLines',FShowGuideLines,
|
||||
true);
|
||||
XMLConfig.SetDeleteValue(Path+'FormEditor/SnapToGuideLines',
|
||||
FSnapToGuideLines,true);
|
||||
XMLConfig.SetDeleteValue(Path+'FormEditor/GuideLineColorLeftTop',
|
||||
FGuideLineColorLeftTop,clGreen);
|
||||
XMLConfig.SetDeleteValue(
|
||||
Path+'FormEditor/GuideLineColorRightBottom',
|
||||
XMLConfig.SetDeleteValue(Path+'FormEditor/GuideLineColorRightBottom',
|
||||
FGuideLineColorRightBottom,clBlue);
|
||||
XMLConfig.SetDeleteValue(Path+'FormEditor/ShowComponentCaptions',
|
||||
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,
|
||||
// synedit
|
||||
SynEditKeyCmds,
|
||||
// protocol
|
||||
IDEProtocol,
|
||||
// compile
|
||||
Compiler, CompilerOptions, CompilerOptionsDlg, CheckCompilerOpts,
|
||||
ImExportCompilerOpts,
|
||||
@ -454,6 +456,7 @@ type
|
||||
procedure AddRecentProjectFileToEnvironment(const AFilename: string);
|
||||
|
||||
// methods for start
|
||||
procedure StartProtocol;
|
||||
procedure LoadGlobalOptions;
|
||||
procedure SetupMainMenu; override;
|
||||
procedure SetupStandardProjectTypes;
|
||||
@ -954,6 +957,7 @@ begin
|
||||
|
||||
// load options
|
||||
CreatePrimaryConfigPath;
|
||||
StartProtocol;
|
||||
LoadGlobalOptions;
|
||||
|
||||
// set the IDE mode to none (= editing mode)
|
||||
@ -1082,6 +1086,8 @@ begin
|
||||
FreeThenNil(SourceNotebook);
|
||||
inherited Destroy;
|
||||
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.Destroy C ');{$ENDIF}
|
||||
|
||||
FreeThenNil(IDEProtocolOpts);
|
||||
DebugLn('[TMainIDE.Destroy] END');
|
||||
end;
|
||||
|
||||
@ -1501,6 +1507,14 @@ procedure TMainIDE.SetupStartProject;
|
||||
dec(i);
|
||||
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
|
||||
ProjectLoaded: Boolean;
|
||||
@ -1511,7 +1525,7 @@ var
|
||||
AFilename: String;
|
||||
begin
|
||||
{$IFDEF IDE_DEBUG}
|
||||
writeln('TMainIDE.Create A ***********');
|
||||
writeln('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
|
||||
@ -1531,13 +1545,24 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
// try loading last project
|
||||
// try loading last project if lazarus didn't fail last time
|
||||
if (not ProjectLoaded)
|
||||
and (not SkipAutoLoadingLastProject)
|
||||
and (EnvironmentOptions.OpenLastProjectAtStart)
|
||||
and (FileExists(EnvironmentOptions.LastSavedProjectFile)) then begin
|
||||
ProjectLoaded:=
|
||||
(DoOpenProjectFile(EnvironmentOptions.LastSavedProjectFile,[])=mrOk);
|
||||
if (not IDEProtocolOpts.LastProjectLoadingCrashed)
|
||||
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;
|
||||
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.SetupStartProject B');{$ENDIF}
|
||||
|
||||
@ -5705,6 +5730,7 @@ begin
|
||||
Result:=Project1.WriteProject([],'');
|
||||
if Result=mrAbort then exit;
|
||||
EnvironmentOptions.LastSavedProjectFile:=Project1.ProjectInfoFile;
|
||||
IDEProtocolOpts.LastProjectLoadingCrashed := False;
|
||||
AddRecentProjectFileToEnvironment(Project1.ProjectInfoFile);
|
||||
SaveIncludeLinks;
|
||||
UpdateCaption;
|
||||
@ -5971,6 +5997,7 @@ begin
|
||||
Project1.Modified:=false;
|
||||
|
||||
IncreaseCompilerParseStamp;
|
||||
IDEProtocolOpts.LastProjectLoadingCrashed := False;
|
||||
Result:=mrOk;
|
||||
{$IFDEF IDE_VERBOSE}
|
||||
debugln('TMainIDE.DoOpenProjectFile end CodeToolBoss.ConsistencyCheck=',CodeToolBoss.ConsistencyCheck);
|
||||
@ -11465,6 +11492,12 @@ begin
|
||||
SaveEnvironment;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.StartProtocol;
|
||||
begin
|
||||
IDEProtocolOpts:=TIDEProtocol.Create;
|
||||
IDEProtocolOpts.Load;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.mnuSearchFindBlockOtherEnd(Sender: TObject);
|
||||
begin
|
||||
DoGoToPascalBlockOtherEnd;
|
||||
@ -11493,6 +11526,9 @@ end.
|
||||
|
||||
{ =============================================================================
|
||||
$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
|
||||
added check for UpdateCaption if MainIDEBar is already destroyed
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user