Fix uninitialized variables and other problems found by the compiler.

git-svn-id: trunk@48451 -
This commit is contained in:
juha 2015-03-22 10:17:35 +00:00
parent 0923ac9836
commit 708afdf966
63 changed files with 146 additions and 137 deletions

View File

@ -273,7 +273,7 @@ end;
function TCustomLEDNumber.GetAbout : string;
begin
// Result := VpVersionStr;
Result := ''; //VpVersionStr;
end;
{=====}

View File

@ -130,11 +130,11 @@ begin
debugln('Source: ==================================================');
debugln(Src);
debugln('==========================================================');
exit;
exit('');
end;
if EndPos<1 then begin
debugln(['ERROR: TFileDescIDEDockableWindow.ExtractTemplate marker "'+EndMarker+'" not found']);
exit;
exit('');
end;
inc(StartPos,length(StartMarker));
Result:=UTF8Trim(copy(Src,StartPos,EndPos-StartPos));

View File

@ -298,8 +298,9 @@ Var
begin
I:=FKnownDicts.IndexOf(ADict);
If (I<>-1) then
Result:=(FKnownDicts.Objects[i] as TDDFile).FFileName;
Result:=(FKnownDicts.Objects[i] as TDDFile).FFileName
Else
Result:='';
end;
{ TDDFile }

View File

@ -78,7 +78,7 @@ end;
procedure TfpIDEExtEditorInsertFileNameForm.FillFilesList;
var
i:integer;
S, Ext:string;
S:string;
begin
LBFiles.Items.Clear;
if Assigned(LazarusIDE) and Assigned(LazarusIDE.ActiveProject) then

View File

@ -63,8 +63,6 @@ uses strutils;
{ TfpwebNewHTMLListForm }
function TfpwebNewHTMLListForm.HtmlText: string;
var
i:integer;
begin
Result:=DupeString('<li> </li>'+LineEnding, SERows.Value);
if RGStyle.ItemIndex = 0 then

View File

@ -113,6 +113,7 @@ function LoadFastReport3(Report: TfrReport; aFileName: string; out Log:string):
var
Reader: Tfr3Reader;
begin
Result := 0;
Reader := Tfr3Reader.Create;
Reader.Report := Report;
try
@ -272,7 +273,6 @@ end;
procedure Tfr3Reader.LoadReport(Node: TDOMNode);
var
Attr: TDOMNode;
S: string;
begin
Report.Clear;
@ -303,7 +303,6 @@ end;
procedure Tfr3Reader.LoadPages(Node: TDOMNode);
var
Page: TfrPage;
i: Integer;
begin
Node := Node.FirstChild;

View File

@ -238,7 +238,6 @@ end;
procedure TlrCrossViewDataSetProperty.GetValues(Proc: TGetStrProc);
var
I: Integer;
Values: TStringList;
var
Lst : TStringList;
begin

View File

@ -2924,7 +2924,6 @@ procedure TfrDesignerForm.GetFontList;
var
DC: HDC;
Lf: TLogFont;
S: String;
{$IFDEF USE_PRINTER_FONTS}
Lst: TStrings;
i: Integer;
@ -3259,7 +3258,6 @@ end;
procedure TfrDesignerForm.FilePreviewExecute(Sender: TObject); // preview
var
v1, v2: Boolean;
TestRepStream:TMemoryStream;
Rep, SaveR:TfrReport;
@ -6382,8 +6380,6 @@ end;
{----------------------------------------------------------------------------}
// menu bitmaps
procedure TfrDesignerForm.SetMenuBitmaps;
var
i: Integer;
begin
MaxItemWidth := 0; MaxShortCutWidth := 0;
@ -7771,7 +7767,6 @@ end;
procedure TfrCustomMemoViewDetailReportProperty.GetValues(Proc: TGetStrProc);
var
I: Integer;
Values: TStringList;
begin
if Assigned(CurReport) then
begin
@ -7821,7 +7816,7 @@ end;
procedure TlrInternalTools.InsertDbFields;
var
i, x, y, dx, dy, pdx, adx, tdx, tdy: Integer;
i, x, y, dx, dy, pdx, adx: Integer;
HeaderL, DataL: TFpList;
t, t1: TfrView;
b: TfrBandView;

View File

@ -137,12 +137,6 @@ procedure TfrDesOptionsForm.FillFonts;
var
DC: HDC;
Lf: TLogFont;
S: String;
{$IFDEF USE_PRINTER_FONTS}
Lst: TStrings;
i: Integer;
j: PtrInt;
{$ENDIF}
begin
ComboBox1.Clear;
DC := GetDC(0);

View File

@ -213,7 +213,7 @@ end;
function THyphen.BreakWord(Word: string): string;
var
i, j: cardinal;
i: cardinal;
hyphens: PChar;
rep: PPChar;
pos: Pointer;
@ -234,10 +234,8 @@ begin
pos := nil;
cut := nil;
try
if hnj_hyphen_hyphenate2(pdict^, PChar(word), Len, hyphens, nil,
rep, pos, cut) = 0 then
if hnj_hyphen_hyphenate2(pdict^, PChar(word), Len, hyphens, nil, rep, pos, cut) = 0 then
begin
j := 0;
for i := 1 to length(hyphens)-1 do
if Odd(Ord(hyphens[i])) then begin
result := result + chr(i+1);

View File

@ -53,7 +53,6 @@ implementation
procedure RegisterLRExportFilter(AFilter: TlrPreviewToolsAbstract);
var
C: Integer;
i: Integer;
begin
for i:=0 to lrExportFilters.Count - 1 do
@ -65,7 +64,6 @@ end;
procedure UnRegisterLRExportFilter(AFilter: TlrPreviewToolsAbstract);
var
C: Integer;
i: Integer;
begin
i:=lrExportFilters.IndexOf(AFilter);

View File

@ -287,7 +287,7 @@ function TfrShapeView.GetClipRgn(rt: TfrRgnType): HRGN;
const
Delta = 10;
var
x1, y1, xp, yp : Integer;
xp : Integer;
Pts : Array[0..6] of TPoint;
min, bx, by, bx1, by1, w1, w2, fw: Integer;
begin

View File

@ -390,7 +390,7 @@ end;
procedure frGetDataSetAndField(ComplexName: String; var DataSet: TfrTDataSet;
out Field: TfrTField);
var
n, i, j: Integer;
n: Integer;
Owner, Component: TComponent;
s1, s2, s3, s4: String;
frDS, F:TfrObject;
@ -1049,7 +1049,7 @@ end;
function UTF8CountWords(const str:string; out WordCount,SpcCount,SpcSize:Integer): TArrUTF8Item;
var
b,i,j,n,len: Integer;
b,i,j,len: Integer;
spc: boolean;
begin
i := 1;

View File

@ -179,6 +179,7 @@ var
HasChanged: boolean;
li: TListItem;
begin
HasChanged:=False;
NewEncoding:=NormalizeEncoding(NewEncodingComboBox.Text);
PreviewListView.BeginUpdate;
PreviewListView.Items.Clear;

View File

@ -475,6 +475,7 @@ var
CommChBeg, CommBeg, CommEnd, i: Integer; // Start and end of comment.
begin
Result:='';
CommBeg:=0;
CommEnd:=Length(aStr);
CommChBeg:=PosEx('//', aStr, aPossibleStartPos);
if CommChBeg<>0 then

View File

@ -1400,7 +1400,9 @@ begin
else
AddToProjectLater(aFileName); // Add to project later.
end;
end;
end
else
Result:=False;
end;
function TConvertDelphiProjPack.CheckPackageDep(AUnitName: string): Boolean;

View File

@ -277,7 +277,9 @@ begin
fGrid.Cells[0,GridEndInd]:=AOldIdent;
fGrid.Cells[1,GridEndInd]:=Result;
Inc(GridEndInd);
end;
end
else
Result:='';
end;

View File

@ -874,6 +874,7 @@ begin
case ABreakpoint.WatchScope of
wpsGlobal: s:= lisWatchScopeGlobal;
wpsLocal: s:= lisWatchScopeLocal;
else s := '';
end;
s := s +' / ';
case ABreakpoint.WatchKind of

View File

@ -1862,7 +1862,7 @@ end;
function TIDEBreakPointGroupList.Add(const AGroup: TIDEBreakPointGroup): Integer;
begin
if (AGroup = nil) or (IndexOf(AGroup) >= 0) then exit;
if (AGroup = nil) or (IndexOf(AGroup) >= 0) then exit(-1);
Result := FList.Add(AGroup);
AGroup.AddReference(Self);
FOwner.DoChanged;

View File

@ -95,7 +95,7 @@ begin
case ShowModal of
mrOk: Result := frOk;
mrCancel: Result := frStop;
else {mrCancel:} Result := frStop;
end;
end;

View File

@ -161,6 +161,7 @@ begin
dcRun: Result := ProcessRun;
dcStop: Result := ProcessStop;
dcEnvironment: Result := ProcessEnvironment(String(APArams[0].VAnsiString), AParams[1].VBoolean);
else Result := False;
end;
end;

View File

@ -888,6 +888,7 @@ function TSelectedControl.GetWidth: integer;
var
r: TRect;
begin
Result := 0;
if FUseCache then
Result := FCachedWidth
else

View File

@ -3958,7 +3958,6 @@ begin
if ShowAlignComponentsDialog(HorizAlignID,VertAlignID)=mrOk then
begin
case HorizAlignID of
0: HorizAlignment:=csaNone;
1: HorizAlignment:=csaSides1;
2: HorizAlignment:=csaCenters;
3: HorizAlignment:=csaSides2;
@ -3966,9 +3965,9 @@ begin
5: HorizAlignment:=csaSpaceEqually;
6: HorizAlignment:=csaSide1SpaceEqually;
7: HorizAlignment:=csaSide2SpaceEqually;
else HorizAlignment:=csaNone; // value=0, this prevents compiler warning.
end;
case VertAlignID of
0: VertAlignment:=csaNone;
1: VertAlignment:=csaSides1;
2: VertAlignment:=csaCenters;
3: VertAlignment:=csaSides2;
@ -3976,6 +3975,7 @@ begin
5: VertAlignment:=csaSpaceEqually;
6: VertAlignment:=csaSide1SpaceEqually;
7: VertAlignment:=csaSide2SpaceEqually;
else VertAlignment:=csaNone; // value=0, this prevents compiler warning.
end;
ControlSelection.AlignComponents(HorizAlignment,VertAlignment);
Modified;
@ -4014,16 +4014,16 @@ begin
if ShowSizeComponentsDialog(HorizSizingID,AWidth,VertSizingID,AHeight) = mrOk then
begin
case HorizSizingID of
0: HorizSizing:=cssNone;
1: HorizSizing:=cssShrinkToSmallest;
2: HorizSizing:=cssGrowToLargest;
3: HorizSizing:=cssFixed;
else HorizSizing:=cssNone; // value=0, this prevents compiler warning.
end;
case VertSizingID of
0: VertSizing:=cssNone;
1: VertSizing:=cssShrinkToSmallest;
2: VertSizing:=cssGrowToLargest;
3: VertSizing:=cssFixed;
else VertSizing:=cssNone; // value=0, this prevents compiler warning.
end;
ControlSelection.SizeComponents(HorizSizing,AWidth,VertSizing,AHeight);
Modified;

View File

@ -733,7 +733,9 @@ begin
temp_coord:=GetMaxCoordinates(DMenuItem.SubMenu, Max_Width, Max_Height);
Max_Width:=temp_coord.Right;
Max_Height:=temp_coord.Bottom;
end;
end
else
temp_coord:=Rect(0,0,0,0);
if (DMenuItem.NextItem <> nil) then
temp_coord:=GetMaxCoordinates(DMenuItem.NextItem, Max_Width, Max_Height);
@ -1779,6 +1781,7 @@ var
DesignerMenuItem: TDesignerMenuItem;
begin
if not (Sender is TPropertyEditor) then Exit;
InvalidateNeeded := False;
for i := 0 to TPropertyEditor(Sender).PropCount - 1 do
begin
Instance := TPropertyEditor(Sender).GetComponent(i);
@ -2251,6 +2254,7 @@ var
i: Integer;
temp_menuitem: TMenuItem;
begin
Result := Nil;
case TheAction of
// Insert new AMenuItem after selected AMenuItem
1: begin

View File

@ -252,6 +252,7 @@ function TMainMenuComponentEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := lisMenuEditor;
else Result := '';;
end;
end;

View File

@ -1630,6 +1630,8 @@ var BackupFilename, CounterFilename: string;
IsPartOfProject: boolean;
begin
Result:=mrOk;
SubDir:='';
BackupFilename:='';
if not (FileExistsUTF8(Filename)) then exit;
// check if file in lpi
IsPartOfProject:=(Project1<>nil)

View File

@ -517,8 +517,10 @@ begin
CurMode:=fBuildModes[i];
Identifier:=BuildModesStringGrid.Cells[fModeNameCol,i+1];
end
else
else begin
CurMode:=nil;
Identifier:='';
end;
// Dialog caption
if Project1<>nil then
Caption:=Format(dlgProjectOptionsFor,[Project1.GetTitleOrName])

View File

@ -1548,6 +1548,7 @@ var
CurPath: String;
p: Integer;
begin
Result:=false;
if Paths='' then exit;
if not IDEMacros.CreateAbsoluteSearchPath(Paths,BaseDir) then exit;
//DebugLn(['SearchInPath START ',Paths]);
@ -1566,7 +1567,6 @@ var
end;
until p>length(Paths);
Filename:='';
Result:=false;
end;
function CheckUnitOwners(CheckSourceDirectories: boolean;
@ -1987,6 +1987,7 @@ begin
Result:=Tool.ExtractSourceName;
end else begin
while CodeNode<>nil do begin
NodeName:='';
case CodeNode.Desc of
ctnVarDefinition:
if Tool.NodeIsResultIdentifier(CodeNode) then
@ -2009,7 +2010,6 @@ begin
ctnIdentifier:
if Tool.NodeIsResultType(CodeNode) then
NodeName:='Result';
else NodeName:='';
end;
if NodeName<>'' then begin
if Result<>'' then

View File

@ -387,7 +387,8 @@ begin
else if Sender=InsertAsChildIfDefMenuItem then DefAction:=da_IfDef
else if Sender=InsertAsChildIfNotDefMenuItem then DefAction:=da_IfNDef
else if Sender=InsertAsChildElseIfMenuItem then DefAction:=da_ElseIf
else if Sender=InsertAsChildElseMenuItem then DefAction:=da_Else;
else if Sender=InsertAsChildElseMenuItem then DefAction:=da_Else
else DefAction:=da_None;
InsertNewNode(Behind,DefAction);
end;
@ -539,7 +540,8 @@ begin
else if Sender=ConvertActionToIfDefMenuItem then NewAction:=da_IfDef
else if Sender=ConvertActionToIfNotDefMenuItem then NewAction:=da_IfNDef
else if Sender=ConvertActionToElseIfMenuItem then NewAction:=da_ElseIf
else if Sender=ConvertActionToElseMenuItem then NewAction:=da_Else;
else if Sender=ConvertActionToElseMenuItem then NewAction:=da_Else
else NewAction:=da_None;
SelDefNode.Action:=NewAction;
SetNodeImages(SelTreeNode,false);
SetTypeLabel;

View File

@ -898,8 +898,10 @@ begin
else
Opt1 := '';
end
else
else begin
Opt2 := '';
Opt1 := aDescr;
end;
if Opt1 <> '' then // Can be empty when line in help output is split.
NewSetElem(Opt1)
else if fCompilerOpts.Count > 0 then

View File

@ -3008,7 +3008,7 @@ begin
end;
{ ------------- Search Paths ---------------- }
CurOutputDir:='';
if not (ccloNoMacroParams in Flags) then
begin
// include path
@ -3043,8 +3043,7 @@ begin
CurOutputDir:=ParsedOpts.GetParsedValue(pcosOutputDir);
if not (ccloAbsolutePaths in Flags) then
CurOutputDir:=CreateRelativePath(CurOutputDir,BaseDirectory,true);
end else
CurOutputDir:='';
end;
if CurOutputDir<>'' then
switches := switches + ' '+PrepareCmdLineOption('-FU'+CurOutputDir);
end;

View File

@ -823,6 +823,7 @@ function TCustomFormEditor.CreateNonFormForm(LookupRoot: TComponent): TCustomNon
var
MediatorClass: TDesignerMediatorClass;
begin
Result := Nil;
if FindNonFormFormNode(LookupRoot) <> nil then
RaiseException(lisCFETCustomFormEditorCreateNonFormFormAlreadyExists);
if LookupRoot is TComponent then

View File

@ -782,7 +782,7 @@ end;
function TDebugManager.DoProjectClose(Sender: TObject; AProject: TLazProject): TModalResult;
begin
if AProject<>Project1 then exit;
if AProject<>Project1 then exit(mrCancel);
ResetDebugger;
Result := mrOK;
end;
@ -1368,8 +1368,10 @@ begin
end;
Editor := nil;
if SourceEditorManager <> nil
then Editor := SourceEditorManager.SourceEditorIntfWithFilename(NewSource.Filename);
if SourceEditorManager <> nil then
Editor := SourceEditorManager.SourceEditorIntfWithFilename(NewSource.Filename)
else
NewSource := Nil;
// jump editor to execution line
Flags := [jfAddJumpPoint, jfSearchVirtualFullPath];

View File

@ -751,9 +751,8 @@ begin
then begin
FHasError := True;
AddError('Wrong amount of param');
exit;
exit(0);
end;
Result := FParams[Index].Num;
end;
@ -763,9 +762,8 @@ begin
then begin
FHasError := True;
AddError('Wrong amount of param');
exit;
exit('');
end;
Result := FParams[Index].Text;
end;
@ -774,9 +772,8 @@ begin
if (Index < 0) or (Index >= Length(FParams)) then begin
FHasError := True;
AddError('Wrong amount of param');
exit;
exit(ptString); // What to return here?
end;
Result := FParams[Index].ParamType;
end;

View File

@ -2353,8 +2353,8 @@ var
Stream: TLazarusResourceStream;
begin
FPResource := FindResource(HInstance, PChar(AResName), PChar(RT_RCDATA));
if FPResource <> 0 then
Stream := TLazarusResourceStream.CreateFromHandle(HInstance, FPResource);
if FPResource = 0 then exit;
Stream := TLazarusResourceStream.CreateFromHandle(HInstance, FPResource);
XMLConfig := TRttiXMLConfig.Create('');
XMLConfig.ReadFromStream(Stream);
Singleton.RegisterScheme(XMLConfig, ASchemeName, 'Lazarus/ColorSchemes/');
@ -2568,10 +2568,7 @@ function TEditOptLanguageInfo.SampleLineToAddAttr(
Line: Integer): TAdditionalHilightAttribute;
begin
if Line < 1 then
begin
Result := ahaNone;
exit;
end;
exit(ahaNone);
for Result := Low(TAdditionalHilightAttribute)
to High(TAdditionalHilightAttribute) do
if (Result <> ahaNone) and (AddAttrSampleLines[Result] = Line) then

View File

@ -1761,6 +1761,7 @@ var
begin
if GetLineAt(HintInfo^.CursorPos.Y,View,Line) then begin
MsgLine:=nil;
s:='';
if Line<0 then
s:=GetHeaderText(View)
else if Line<View.Lines.Count then begin
@ -3140,7 +3141,7 @@ begin
MinUrgency:=mluHint
else if Sender=MsgFilterDebugMenuItem then
MinUrgency:=mluVerbose3
else if Sender=MsgFilterNoneMenuItem then
else {if Sender=MsgFilterNoneMenuItem then}
MinUrgency:=mluNone;
MessagesCtrl.ActiveFilter.MinUrgency:=MinUrgency;
//debugln(['TMessagesFrame.FilterUrgencyMenuItemClick ',MessageLineUrgencyNames[MinUrgency]]);

View File

@ -883,7 +883,7 @@ begin
{$ENDIF}
if (FromPosY=ToPosY) and (FromPosX=ToPosX) then
exit; // no change => ignore
exit(nil); // no change => ignore
// consistency check
if IsCaretInFront(ToPosY,ToPosX,FromPosY,FromPosX) then

View File

@ -474,7 +474,7 @@ var
Src: TExternalUserTools;
i: Integer;
begin
if Obj=Self then exit;
if Obj=Self then exit(true);
if Obj is TExternalUserTools then begin
Src:=TExternalUserTools(Obj);
Result:=false;

View File

@ -471,7 +471,7 @@ function TFindOverloadsWorker.AddFileToScan(const Filename: string;
CheckExtension: boolean): TFOWFile;
begin
if CheckExtension and (not FilenameIsPascalSource(Filename)) then
exit;
exit(nil);
Result:=FindFile(Filename);
if Result<>nil then exit;
Result:=TFOWFile.Create(Filename);

View File

@ -1056,7 +1056,7 @@ end;
function TFPDocEditor.GUIModified: boolean;
begin
if fpdefReading in FFlags then exit;
if fpdefReading in FFlags then exit(false);
Result:=(ShortEdit.Text<>FOldVisualValues[fpdiShort])
or (LinkEdit.Text<>FOldVisualValues[fpdiElementLink])
or (DescrMemo.Text<>FOldVisualValues[fpdiDescription])

View File

@ -441,11 +441,12 @@ begin
end;
if (ModuleOwner<>nil) and (ModuleOwner<>StartModuleOwner) then begin
// different module
if ModuleOwner is TLazProject then begin
ModuleName:=lowercase(ExtractFileNameOnly(TLazProject(ModuleOwner).ProjectInfoFile));
end else if ModuleOwner is TLazPackage then begin
ModuleName:=TLazPackage(ModuleOwner).Name;
end;
if ModuleOwner is TLazProject then
ModuleName:=lowercase(ExtractFileNameOnly(TLazProject(ModuleOwner).ProjectInfoFile))
else if ModuleOwner is TLazPackage then
ModuleName:=TLazPackage(ModuleOwner).Name
else
ModuleName:='';
if ModuleName<>'' then
ElementName:='#'+ModuleName+'.'+ElementName
else

View File

@ -399,6 +399,8 @@ function TCompOptBuildMacrosFrame.GetNodeInfo(Node: TTreeNode;
case ParentType of
cbmntBuildMacro:
Result:=cbmntValue;
else
Result:=cbmntNone;
end;
end;
end;

View File

@ -1072,6 +1072,7 @@ begin
ColorElementTree.Items.Add(nil, AdditionalHighlightGroupNames[j]);
// Fill Attributes in
DefNode := nil;
for i := 0 to FCurrentColorScheme.AttributeCount - 1 do begin
Attr := FCurrentColorScheme.AttributeAtPos[i];
if Attr.StoredName <> '' then begin

View File

@ -2603,12 +2603,11 @@ var
Count1: Int64;
Count2: Int64;
begin
Result:=false;
if s1.Memory=nil then begin
Result:=s2.Memory=nil;
end else begin
if s2.Memory=nil then begin
Result:=false;
end else begin
if s2.Memory<>nil then begin
p1:=PChar(s1.Memory);
p2:=PChar(s2.Memory);
Count1:=s1.Size;

View File

@ -656,6 +656,7 @@ var
MsgResult: TModalResult;
begin
Node:=FirstErrorNode;
s:='';
if Node=TVNodeLazarus then
s:=lisWithoutAProperLazarusDirectoryYouWillGetALotOfWarn
else if Node=TVNodeCompiler then

View File

@ -163,7 +163,7 @@ var
HasLinefeed: Boolean;
begin
if InText = '' then
Exit;
Exit('');
HasLinefeed := InText[Length(InText)] in [#10,#13];
InLines := TStringList.Create;
InLines.Text := InText;

View File

@ -1885,7 +1885,7 @@ var
begin
ActiveSrcEdit:=nil;
if not BeginCodeTool(ActiveSrcEdit,ActiveUnitInfo,[ctfSwitchToFormSource]) then
Exit;
Exit(False);
{$IFDEF IDE_DEBUG}
debugln('');
debugln('[TMainIDE.OnPropHookCompatibleMethodExists] ************ ',AMethodName);
@ -11977,7 +11977,7 @@ var
begin
ActiveSrcEdit:=nil;
if not BeginCodeTool(ActiveSrcEdit,ActiveUnitInfo,[ctfSwitchToFormSource]) then
Exit;
Exit(False);
{$IFDEF IDE_DEBUG}
debugln('');
debugln('[TMainIDE.OnPropHookMethodExists] ************ ',AMethodName);

View File

@ -404,6 +404,7 @@ begin
else exit(false);
end;
end;
Result:=true;
end;
function TMainIDEInterface.DoJumpToSourcePosition(const Filename: string; NewX, NewY,

View File

@ -171,11 +171,8 @@ var
c: Char;
i: Integer;
begin
if SubStr='' then
begin
Result := true;
end
else
Result := SubStr='';
if not Result then
begin
Src := PChar(Str);
PFilter := PChar(SubStr);

View File

@ -2271,7 +2271,9 @@ end;
function TUnitInfo.AddBookmark(X, Y, ID: integer): integer;
begin
if FSetBookmarLock = 0 then
Result := Bookmarks.Add(X, Y, ID);
Result := Bookmarks.Add(X, Y, ID)
else
Result := -1;
SessionModified := True;
Project1.AddBookmark(X, Y, ID, Self);
end;
@ -3983,7 +3985,7 @@ var CodeBuf: TCodeBuffer;
begin
CodeBuf:=GetResourceFile(AnUnitInfo,1);
if CodeBuf=nil then begin
if AnUnitInfo.Filename='' then exit;
if AnUnitInfo.Filename='' then exit('');
Result:=ChangeFileExt(AnUnitInfo.Filename,ResourceFileExt);
exit;
end else
@ -6095,7 +6097,9 @@ var
begin
MainUnitInfo:=FProject.MainUnitInfo;
if (MainUnitInfo<>nil) then
Result:=ExtractFileName(MainUnitInfo.Filename);
Result:=ExtractFileName(MainUnitInfo.Filename)
else
Result:='';
if Result='' then
Result:=inherited GetDefaultMainSourceFileName;
end;

View File

@ -1481,7 +1481,9 @@ function TProjectManualProgramDescriptor.CreateStartFiles(AProject: TLazProject
begin
if AProject.MainFile<>nil then
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
[ofProjectLoading,ofRegularFile]);
[ofProjectLoading,ofRegularFile])
else
Result:=mrCancel;
end;
{ TProjectEmptyProgramDescriptor }

View File

@ -778,13 +778,12 @@ function TProjectResources.Save(SaveToTestDir: string): Boolean;
CodeBuf: TCodeBuffer;
TestFilename: String;
begin
Result := True;
CodeBuf := CodeToolBoss.FindFile(Filename);
if (CodeBuf = nil) or CodeBuf.IsDeleted then
Exit(True);
if (CodeBuf = nil) or CodeBuf.IsDeleted then Exit;
if not CodeBuf.IsVirtual then
begin
Result := SaveCodeBuffer(CodeBuf) in [mrOk,mrIgnore];
end else if SaveToTestDir<>'' then
Result := SaveCodeBuffer(CodeBuf) in [mrOk,mrIgnore]
else if SaveToTestDir<>'' then
begin
TestFilename := AppendPathDelim(SaveToTestDir) + CodeBuf.Filename;
Result := SaveCodeBufferToFile(CodeBuf, TestFilename) in [mrOk, mrIgnore];

View File

@ -752,16 +752,16 @@ begin
PopupMenu := popList;
NewTreeView.Canvas.Brush.Color:= clWhite;
end;//with
SearchObj:=NewTreeView.SearchObject;
if SearchObj<>nil then begin
SearchObj.SearchString:= SearchText;
SearchObj.ReplaceText := ReplaceText;
SearchObj.SearchDirectories:= ADirectories;
SearchObj.SearchMask:= AMask;
SearchObj.SearchOptions:= TheOptions;
end;
NewTreeView.Skipped:=0;
end;//if
SearchObj:=NewTreeView.SearchObject;
if SearchObj<>nil then begin
SearchObj.SearchString:= SearchText;
SearchObj.ReplaceText := ReplaceText;
SearchObj.SearchDirectories:= ADirectories;
SearchObj.SearchMask:= AMask;
SearchObj.SearchOptions:= TheOptions;
end;
NewTreeView.Skipped:=0;
Result:= Pages[PageIndex];
SearchInListEdit.Text:='';
SearchInListEdit.Filter:='';

View File

@ -1226,6 +1226,7 @@ begin
CurPath:=AppendPathDelim(ExtractFilePath(FActiveUnitInfo.Filename))+CurPath;
end;
for c:=0 to 2 do begin
TempFile:='';
// FPC searches first lowercase, then keeping case, then uppercase
case c of
0: TempFile:=LowerCase(FFileName);
@ -1755,6 +1756,7 @@ begin
// syntax highlighter type
NewUnitInfo.DefaultSyntaxHighlighter := FilenameToLazSyntaxHighlighter(NewFilename);
NewSrcEdit := Nil;
if nfOpenInEditor in NewFlags then begin
// open a new sourceeditor
SrcNoteBook := SourceEditorManager.ActiveOrNewSourceWindow;
@ -2101,6 +2103,7 @@ begin
end;
// b) do actual save
DestFilename := '';
if (sfSaveToTestDir in Flags) or AnUnitInfo.IsVirtual then
begin
// save source to test directory
@ -2484,7 +2487,7 @@ var
SearchPath: String;
SearchFile: String;
begin
if CompiledSrcExt='' then exit;
if CompiledSrcExt='' then exit('');
// get unit path for compiled units
UnitPath:=BaseDir+';'+StartUnitPath;
UnitPath:=TrimSearchPath(UnitPath,BaseDir);
@ -3551,7 +3554,7 @@ var
begin
//debugln('[TLazSourceFileManager.CreateProjectForProgram] A ',ProgramBuf.Filename);
if (Project1 <> nil)
and (not MainIDE.DoResetToolStatus([rfInteractive, rfSuccessOnTrigger])) then exit;
and (not MainIDE.DoResetToolStatus([rfInteractive, rfSuccessOnTrigger])) then exit(mrAbort);
Result:=SaveProjectIfChanged;
if Result=mrAbort then exit;
@ -6989,6 +6992,7 @@ var
DestFilename: String;
SkipSavingMainSource: Boolean;
begin
Result:=mrOk;
Project1.ActiveWindowIndexAtStart := SourceEditorManager.ActiveSourceWindowIndex;
// update source notebook page names
@ -7023,7 +7027,6 @@ begin
AddRecentProjectFileToEnvironment(Project1.ProjectInfoFile);
MainIDE.SaveIncludeLinks;
MainIDE.UpdateCaption;
if Result=mrAbort then exit;
end;
// save main source
@ -7062,8 +7065,6 @@ begin
end;
end;
end;
Result:=mrOk;
end;
procedure TLazSourceFileManager.GetMainUnit(out MainUnitInfo: TUnitInfo; out

View File

@ -815,6 +815,8 @@ var
NewBounds: TSynSearchTermOptsBounds;
begin
NewTerm := '';
B1 := False;
B2 := False;
if syn.SelAvail and (syn.BlockBegin.y = syn.BlockEnd.y) then begin
NewTerm := syn.SelText;
LineTxt := syn.Lines[syn.CaretY-1];

View File

@ -1043,7 +1043,7 @@ var
CurUnit: TUGUnit;
ProjFile: TLazProjectFile;
begin
if AProject=nil then exit;
if AProject=nil then exit(nil);
Result:=Groups.GetGroup(GroupPrefixProject,true);
Result.BaseDir:=ExtractFilePath(AProject.ProjectInfoFile);
if not FilenameIsAbsolute(Result.BaseDir) then
@ -1070,7 +1070,7 @@ var
Filename: String;
CurUnit: TUGUnit;
begin
if APackage=nil then exit;
if APackage=nil then exit(nil);
Result:=Groups.GetGroup(APackage.Name,true);
Result.BaseDir:=APackage.DirectoryExpanded;
if not FilenameIsAbsolute(Result.BaseDir) then

View File

@ -85,6 +85,7 @@ var
Code: TCodeBuffer;
begin
// get cursor position
Result:=mrAbort;
SrcEdit:=SourceEditorManagerIntf.ActiveEditor;
if SrcEdit=nil then exit;
Code:=TCodeBuffer(SrcEdit.CodeToolsBuffer);

View File

@ -369,7 +369,9 @@ begin
Result:=TLazPackage(DepOwner).IDAsString
else
Result:=TLazPackage(DepOwner).Name;
end;
end
else
Result:='';
end;
function TCleanPkgDepsDlg.FetchDeletes: TObjectList;

View File

@ -430,10 +430,8 @@ var
Count: Integer;
begin
Count := 0;
if MyFile.Count < 0 then begin
Result := 0;
exit;
end;
if MyFile.Count < 0 then
exit(0);
for I := 0 to MyFile.Count -1 do begin
// find start of TYPE
if pos('TYPE', uppercase(MyFile[i])) > 0 then begin
@ -448,12 +446,10 @@ begin
if 'IMPLEMENTATION' = uppercase(MyFile[J]) then begin
// that's it
//messagedlg('Found IMPLEMENTATION at '+inttostr(J),mtInformation,[mbOk],0);
Result := Count;
exit;
exit(Count);
end;
end; // For J
Result := Count;
exit;
exit(Count);
end; // if pos('TYPE');
end; // for I
@ -465,11 +461,10 @@ var
TempStr: String;
Count: Integer;
begin
Result := '';
Count := 0;
if MyFile.Count < 0 then begin
Result := '';
if MyFile.Count < 0 then
exit;
end;
for K := 0 to MyFile.Count -1 do begin
// find start of TYPE
if pos('TYPE', uppercase(MyFile[K])) > 0 then begin
@ -478,20 +473,15 @@ begin
(pos('=CLASS', uppercase(MyFile[j])) > 0)) then begin
// found one!
Count := Count + 1;
if Count = I then begin
TempStr := Trim(copy(MyFile[J],1,pos('=',MyFile[j])-1));
Result := TempStr;
exit;
end;
if Count = I then
exit(Trim(copy(MyFile[J],1,pos('=',MyFile[j])-1)));
end; // if class
if 'IMPLEMENTATION' = uppercase(MyFile[J]) then begin
// that's it
//messagedlg('Found IMPLEMENTATION at '+inttostr(J),mtInformation,[mbOk],0);
Result := '';
exit;
end;
end; // For J
Result := '';
exit;
end; // if pos('TYPE');
end; // for I
@ -503,14 +493,14 @@ var
I: Integer;
TempStr: String;
begin
Result := '';
if MyFile.Count < 1 then exit;
for I := 0 to MyFile.Count - 1 do begin
if uppercase(copy(MyFile[i],1,4)) = 'UNIT' then begin
TempStr := copy(MyFile[i],5,64);
TempStr := trim(TempStr);
if copy(TempStr,length(TempStr),1) = ';' then TempStr := copy(TempStr,1,length(TempStr)-1);
Result := TempStr;
exit;
exit(TempStr);
end; // if UNIT found
end; // for I
end;

View File

@ -4140,7 +4140,9 @@ end;
function TPkgCompilerOptions.GetOwnerName: string;
begin
if LazPackage<>nil then
Result:=LazPackage.IDAsString;
Result:=LazPackage.IDAsString
else
Result:='';
end;
procedure TPkgCompilerOptions.InvalidateOptions;

View File

@ -2910,6 +2910,7 @@ begin
ShortDirectory:=NewDirectory;
LazPackage.ShortenFilename(ShortDirectory,true);
if ShortDirectory='' then exit;
ShortIncDirectory:='';
LazPackage.LongenFilename(NewDirectory);
NewDirectory:=ChompPathDelim(NewDirectory);
@ -3031,6 +3032,7 @@ begin
else exit(false);
end;
end;
Result:=true;
end;
function TPackageEditorForm.FilesEditTreeView: TTreeView;

View File

@ -713,7 +713,7 @@ end;
function TLazPkgGraphBuildItem.Add(Tool: TAbstractExternalTool): integer;
begin
if Tool=nil then exit;
if Tool=nil then exit(-1);
Tool.Reference(Self,'TLazPkgGraphBuildItem.Add');
if Tool.Data is TLazPkgGraphExtToolData then
TLazPkgGraphExtToolData(Tool.Data).BuildItem:=Self;

View File

@ -3285,6 +3285,7 @@ function TPkgManager.OpenProjectDependencies(AProject: TProject;
var
BrokenDependencies: TFPList;
begin
Result:=mrOk;
PackageGraph.OpenRequiredDependencyList(AProject.FirstRequiredDependency);
if ReportMissing then begin
BrokenDependencies:=PackageGraph.FindAllBrokenDependencies(nil,
@ -3293,8 +3294,7 @@ begin
Result:=ShowBrokenDependenciesReport(BrokenDependencies);
BrokenDependencies.Free;
end;
end else
Result:=mrOk;
end;
PkgLinks.SaveUserLinks;
end;
@ -5016,6 +5016,7 @@ begin
else begin
APackage.LPKSource:=nil;
APackage.Missing:=true;
Result:=mrCancel;
end;
debugln(['Hint: (lazarus) [TPkgManager.RevertPackages] AFTER ',PackageGraph.FindPackageWithFilename(Filename)<>nil]);
if Result=mrAbort then exit;
@ -5033,7 +5034,7 @@ var
HasRegisterProc: Boolean;
begin
MainIDE.GetCurrentUnitInfo(ActiveSourceEditor,ActiveUnitInfo);
if ActiveSourceEditor=nil then exit;
if ActiveSourceEditor=nil then exit(mrAbort);
Filename:=ActiveUnitInfo.Filename;