MG: fixed outputfilter for linker errors

git-svn-id: trunk@1591 -
This commit is contained in:
lazarus 2002-04-04 17:21:18 +00:00
parent 31798d03be
commit a9df41ade4
3 changed files with 49 additions and 34 deletions

View File

@ -343,6 +343,8 @@ type
IsPartOfProject:boolean): TModalResult;
procedure UpdateCaption;
procedure UpdateDefaultPascalFileExtensions;
function CreateSrcEditPageName(const AnUnitName, AFilename: string;
IgnorePageIndex: integer): string;
// methods for codetools
procedure InitCodeToolBoss;
@ -2160,6 +2162,19 @@ begin
then ProjectDefaultExt[npt]:=DefPasExt;
end;
function TMainIDE.CreateSrcEditPageName(const AnUnitName, AFilename: string;
IgnorePageIndex: integer): string;
begin
Result:=AnUnitName;
if Result='' then
Result:=AFilename;
if FilenameIsPascalUnit(Result) then
Result:=ExtractFileNameOnly(Result)
else
Result:=ExtractFileName(Result);
Result:=SourceNoteBook.FindUniquePageName(Result,IgnorePageIndex);
end;
procedure TMainIDE.OnLoadEnvironmentSettings(Sender: TObject;
TheEnvironmentOptions: TEnvironmentOptions);
begin
@ -2396,8 +2411,7 @@ function TMainIDE.DoShowSaveFileAsDialog(AnUnitInfo: TUnitInfo;
var
SaveDialog: TSaveDialog;
SaveAsFilename, SaveAsFileExt, NewFilename, NewUnitName, NewFilePath,
NewResFilename, NewResFilePath, OldFilePath, NewPageName,
NewLFMFilename: string;
NewResFilename, NewResFilePath, OldFilePath, NewLFMFilename: string;
ACaption, AText: string;
SrcEdit: TSourceEditor;
NewSource: TCodeBuffer;
@ -2567,15 +2581,9 @@ writeln('TMainIDE.ShowSaveFileAsDialog C ',ResourceCode<>nil);
ResourceCode:=CodeToolBoss.FindNextResourceFile(NewSource,LinkIndex);
// change unitname on SourceNotebook
if FilenameIsPascalUnit(NewFilename) then
NewPageName:=NewUnitName
else
NewPageName:=ExtractFileName(NewFilename);
NewPageName:=SourceNoteBook.FindUniquePageName(
NewPageName,SourceNoteBook.NoteBook.PageIndex);
SourceNoteBook.NoteBook.Pages[SourceNoteBook.NoteBook.PageIndex]:=
NewPageName;
SrcEdit.ShortName:=NewPageName;
CreateSrcEditPageName(NewUnitName,NewFilename,
SourceNoteBook.NoteBook.PageIndex);
Result:=mrOk;
end;
@ -2733,7 +2741,6 @@ end;
function TMainIDE.DoOpenNotExistingFile(const AFileName: string;
Flags: TOpenFlags): TModalResult;
var Ext: string;
begin
if ofProjectLoading in Flags then begin
// this is a file, that was loaded last time, but was removed from disk
@ -2753,8 +2760,7 @@ begin
,mtInformation,[mbYes,mbNo],0)=mrYes) then
begin
// create new file
Ext:=lowercase(ExtractFileExt(AFilename));
if FilenameIsPascalUnit(AFilename) or (Ext='.dpr') then
if FilenameIsPascalSource(AFilename) then
Result:=DoNewEditorUnit(nuUnit,AFilename)
else
Result:=DoNewEditorUnit(nuEmpty,AFilename);
@ -2942,7 +2948,7 @@ begin
end;
end;
{$IFDEF IDE_DEBUG}
writeln('[TMainIDE.DoOpenEditorFile] LFM end');
writeln('[TMainIDE.DoLoadLFM] LFM end');
{$ENDIF}
finally
BinLFMStream.Free;
@ -3002,7 +3008,7 @@ var
MainUnitSrcEdit: TSourceEditor;
MainUnitInfo: TUnitInfo;
SaveDialog: TSaveDialog;
NewFilename, NewProgramFilename, NewPageName, NewProgramName, AText, ACaption,
NewFilename, NewProgramFilename, NewProgramName, AText, ACaption,
Ext: string;
NewBuf: TCodeBuffer;
OldProjectPath: string;
@ -3167,15 +3173,10 @@ begin
// update source editor of main unit
MainUnitInfo.Modified:=true;
if FilenameIsPascalUnit(MainUnitInfo.Filename) then
NewPageName:=NewProgramName
else
NewPageName:=ExtractFileName(MainUnitInfo.Filename);
if MainUnitInfo.EditorIndex>=0 then begin
NewPageName:=SourceNoteBook.FindUniquePageName(
NewPageName,MainUnitInfo.EditorIndex);
SourceNoteBook.NoteBook.Pages[MainUnitInfo.EditorIndex]:=
NewPageName;
CreateSrcEditPageName(NewProgramName,MainUnitInfo.Filename,
MainUnitInfo.EditorIndex);
end;
end;
Result:=mrOk;
@ -3193,22 +3194,15 @@ end;
function TMainIDE.DoOpenFileInSourceNotebook(AnUnitInfo: TUnitInfo;
Flags: TOpenFlags): TModalResult;
var NewSrcEdit: TSourceEditor;
NewPageName, AFilename: string;
AFilename: string;
begin
AFilename:=AnUnitInfo.Filename;
// create a new source editor
AnUnitInfo.SyntaxHighlighter:=
ExtensionToLazSyntaxHighlighter(ExtractFileExt(AFilename));
NewPageName:=AnUnitInfo.UnitName;
if NewPageName='' then begin
if FilenameIsPascalUnit(AFilename) then
NewPageName:=ExtractFileNameOnly(AFilename)
else
NewPageName:=ExtractFileName(AFilename);
if NewpageName='' then NewPageName:='file';
end;
SourceNotebook.NewFile(NewPageName,AnUnitInfo.Source);
SourceNotebook.NewFile(CreateSrcEditPageName(AnUnitInfo.UnitName,
AFilename,-1),AnUnitInfo.Source);
NewSrcEdit:=SourceNotebook.GetActiveSE;
if ofProjectLoading in Flags then begin
@ -3275,7 +3269,9 @@ writeln('TMainIDE.DoNewEditorUnit A NewFilename=',NewFilename);
end;
// create a new sourceeditor
SourceNotebook.NewFile(NewUnitInfo.UnitName,NewUnitInfo.Source);
SourceNotebook.NewFile(CreateSrcEditPageName(NewUnitInfo.UnitName,
NewUnitInfo.Filename,-1),
NewUnitInfo.Source);
NewSrcEdit:=SourceNotebook.GetActiveSE;
NewSrcEdit.SyntaxHighlighterType:=NewUnitInfo.SyntaxHighlighter;
Project1.InsertEditorIndex(SourceNotebook.NoteBook.PageIndex);
@ -6205,6 +6201,9 @@ end.
{ =============================================================================
$Log$
Revision 1.271 2002/04/04 17:21:17 lazarus
MG: fixed outputfilter for linker errors
Revision 1.270 2002/04/03 18:20:49 lazarus
MG: fixed mem leaks

View File

@ -130,6 +130,7 @@ const
var
i, Count, LineStart : longint;
OutputLine, Buf : String;
ErrorExists: boolean;
begin
TheProcess.Execute;
fCurrentDirectory:=TheProcess.CurrentDirectory;
@ -144,6 +145,7 @@ begin
fFilteredOutput.Clear;
OutputLine:='';
ErrorExists:=false;
repeat
if TheProcess.Output<>nil then
Count:=TheProcess.Output.Read(Buf[1],length(Buf))
@ -155,6 +157,8 @@ begin
if Buf[i] in [#10,#13] then begin
OutputLine:=OutputLine+copy(Buf,LineStart,i-LineStart);
ReadLine(OutputLine,false);
if fLastErrorType in [etFatal, etPanic, etError] then
ErrorExists:=true;
OutputLine:='';
if (i<Count) and (Buf[i+1] in [#10,#13]) and (Buf[i]<>Buf[i+1])
then
@ -166,6 +170,8 @@ begin
OutputLine:=copy(Buf,LineStart,Count-LineStart+1);
until Count=0;
TheProcess.WaitOnExit;
if ErrorExists and (ofoExceptionOnError in Options) then
raise EOutputFilterError.Create('there was an error');
end;
procedure TOutputFilter.ReadLine(const s: string; DontFilterLine: boolean);
@ -266,6 +272,8 @@ begin
// this is a freepascal compiler message
// -> filter message
fLastErrorType:=MsgType;
fLastMessageType:=omtFPC;
SkipMessage:=true;
if Project<>nil then begin
case MsgType of
@ -336,17 +344,22 @@ begin
end;
end;
// make filenames absolute if wanted
if (ofoMakeFilenamesAbsolute in Options) then begin
Filename:=copy(Msg,1,FilenameEndPos);
if not FilenameIsAbsolute(Filename) then begin
Msg:=fCurrentDirectory+Msg;
end;
end;
// add line
if not SkipMessage then
DoAddFilteredLine(Msg);
if (ofoExceptionOnError in Options) and (MsgType in [etPanic, etFatal])
then
raise EOutputFilterError.Create(Msg);
Result:=true;
exit;
end;

View File

@ -1275,7 +1275,7 @@ begin
end else
Result:=false;
end else
Result:=IsVirtual;
Result:=true;
end;
procedure TProject.OnUnitNameChange(AnUnitInfo: TUnitInfo;
@ -1353,6 +1353,9 @@ end.
{
$Log$
Revision 1.59 2002/04/04 17:21:18 lazarus
MG: fixed outputfilter for linker errors
Revision 1.58 2002/04/02 17:18:25 lazarus
MG: fixed save project as, renaming source name