Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mostly cleanup #59

Open
wants to merge 14 commits into
base: development
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reduce compiler warnings and notes. Fix uninitialized vars + other po…
…tential problems.
  • Loading branch information
JuhaManninen committed Feb 2, 2020
commit 60caf53461848ebab8b9664e259438804f2de757
25 changes: 13 additions & 12 deletions Source/Units/amoebes.pas
Original file line number Diff line number Diff line change
@@ -347,7 +347,7 @@ procedure TAmoebeSerie.SetTitle(Value : string);
end;

Procedure TAmoebeSerie.SetNormLength(Value : LongInt);
var L : LongInt;
//var L : LongInt;
begin
if (Value > 0) and (FNorm > FMinValue) then
begin
@@ -628,6 +628,7 @@ procedure TAmoebeSerie.SetStartPoint(Value : TPoint);
end;
end;
Cnvs.Brush.Style:= bsSolid;
{$warning TAmoebeSerie.DrawModern: Color BC is not initialized!}
Cnvs.Brush.Color:= BC;
end;
end;
@@ -697,7 +698,7 @@ constructor TAmoebe.Create(AOwner : TComponent);
end;

Procedure TAmoebe.Initialize;
var i : LongInt;
var //i : LongInt;
P : TPoint;
begin
FFitting:= false;
@@ -846,6 +847,7 @@ procedure TAmoebe.Print;

Function TAmoebe.DrawTitle(Cnvs : TCanvas; Rect : TRect) : LongInt;
begin
Result:= 0; // What should be returned?
if FTitle <> '' then
begin
Cnvs.Brush.Style:= bsClear;
@@ -859,7 +861,7 @@ procedure TAmoebe.Print;
var i, j : LongInt;
Serie, Serie2 : TAmoebeSerie;
PA : array of TPoint;
L, A : double;
//A : double;
begin
//Teken eerst normcircel met kleur, dan de amoebe, dan de normcirkel leeg
//en tenslotte de assen
@@ -879,10 +881,11 @@ procedure TAmoebe.Print;
System.SetLength(PA, 3)
else
System.SetLength(PA, FSeries.Count);

{ if FSeries.Count > 1 then
A:= 0.5 * TAmoebeSerie(FSeries.Items[1]).Angle
else
A:= 90; }
j:= 0;
if FSeries.Count > 1 then A:= 0.5 * TAmoebeSerie(FSeries.Items[1]).Angle
else A:= 90;
for i:= 1 to FSeries.Count do
begin
Serie:= TAmoebeSerie(FSeries.Items[i-1]);
@@ -925,10 +928,9 @@ procedure TAmoebe.Print;
end;

Procedure TAmoebe.DrawModern(Cnvs : TCanvas; Re : TRect);
var i, j : LongInt;
var i : LongInt;
Serie : TAmoebeSerie;
PA : array of TPoint;
L, A : double;
begin
//Teken eerst normcircel met kleur, dan de amoebe, dan de normcirkel leeg
//en tenslotte de assen
@@ -1013,7 +1015,7 @@ procedure TAmoebe.Print;
end;

Procedure TAmoebe.DrawSlices(Cnvs : TCanvas; Re : TRect);
var i, j : LongInt;
var i : LongInt;
Serie : TAmoebeSerie;
L, A, A2 : double;
L2, X1, X2, X3, X4, Y1, Y2, Y3, Y4 : integer;
@@ -1032,7 +1034,6 @@ procedure TAmoebe.Print;
begin
if FSeries.Count > 1 then A:= TAmoebeSerie(FSeries.Items[1]).Angle
else A:= 45;
j:= 0;
Cnvs.Brush.Style:= bsSolid;
Cnvs.Brush.Color:= FAmoebeColor;
Cnvs.Pen.Color:= clBlack;
@@ -1168,7 +1169,6 @@ procedure TAmoebe.Print;

Procedure TAmoebe.SetAmountSeries(Value : LongInt);
var i : LongInt;
Serie : TAmoebeSerie;
begin
if Value < 0 then Value:= 0;
if FSeries = NIL then FSeries:= TList.Create;
@@ -1500,6 +1500,7 @@ procedure TAmoebe.SetSerieFont(SerieNr : LongInt; Value : TFont);

Function TAmoebe.ExecuteEditor : boolean;
begin
Result:= True;
{ if FAllowEditor then
begin
Application.CreateForm(TFrmAmoebeDlg, FrmAmoebeDlg);
@@ -1544,4 +1545,4 @@ procedure TAmoebe.Assign(Source : TPersistent);
end;

end.


4 changes: 3 additions & 1 deletion Source/Units/bhgraphics.pas
Original file line number Diff line number Diff line change
@@ -964,14 +964,16 @@ implementation

Function PolyPolygon(Canvas : TCanvas; Points: array of TPoint; {PolyCounts : array of integer;} AmPoly : integer) : boolean;
begin
Result:= True;
Canvas.Polygon(Points, {PolyCounts,} AmPoly, false);
end;

Function PolyRoundedLine(Canvas : TCanvas; Points : array of TPoint; RoundPerc : single) : boolean;
var i, j, Max, dX, dY : LongInt;
var i, dX, dY : LongInt;
PB : array[1..4] of TPoint;
Line : array[1..2] of TPoint;
begin
Result:= True;
if RoundPerc < 0 then RoundPerc:= 0;
if RoundPerc > 50 then RoundPerc:= 50;
Line[1].X:= Points[0].X; Line[1].Y:= Points[0].Y;
28 changes: 12 additions & 16 deletions Source/Units/bhprintforms.pas
Original file line number Diff line number Diff line change
@@ -25,13 +25,11 @@ TIngrListItem = record
Caption : string;
IngrType : TIngredientType;
end;

TIngrListArray = array of TIngrListItem;
//TIngrListArray = array of TIngrListItem;

var Head1FontSize, Head2FontSize, Head3FontSize: word;
TextFontSize: word;
clHead, clOneven, clEven : TColor;
IngrListArray : TIngrListArray;

Function CmToPixX(cm : single) : word;
begin
@@ -204,7 +202,7 @@ TIngrListItem = record
Function CreateCheckList(Doc : TBHRDocument; Rec : TRecipe) : boolean;
var i, j : integer;
txt : TBHRText;
Space : TBHRElement;
{%H-}Space : TBHRElement;
logo : TImage;
R : TRect;
LineSpace : word;
@@ -264,8 +262,8 @@ TIngrListItem = record
txt : TBHRText;
logo : TImage;
tbl : TBHRTable;
chart : TBHRChart;
Space : TBHRElement;
{%H-}chart : TBHRChart;
{%H-}Space : TBHRElement;
R : TRect;
v : double;
LineSpace : word;
@@ -2532,11 +2530,10 @@ TIngrListItem = record

Function CreateStockList(Doc : TBHRDocument) : boolean;
var i, nRows, nCols, Ro, Co : integer;
txt : TBHRText;
// img : TBHRImage;
{%H-}txt : TBHRText;
logo : TImage;
tbl : TBHRTable;
Space : TBHRElement;
{%H-}Space : TBHRElement;
R : TRect;
LineSpace : word;
s : string;
@@ -2900,7 +2897,6 @@ TIngrListItem = record
F : TFermentable;
H : THop;
Y : TYeast;
wi : word;
const ItemLength = 40;
begin
Result:= false;
@@ -3033,21 +3029,20 @@ TIngrListItem = record
end;

Function CreateStockListFile : boolean;
var i, j : integer;
var i : integer;
Memo : TMemo;
dlg : TSaveDialog;
s, FN : string;
M : TMisc;
F : TFermentable;
H : THop;
Y : TYeast;
wi : word;
ds, ls : char;
const ItemLength = 40;
begin
Result:= false;
ds:= DecimalSeparator;
ls:= ListSeparator;
ds:= DefaultFormatSettings.DecimalSeparator;
ls:= DefaultFormatSettings.ListSeparator;
if ds = ls then ls:= ';';

Application.ProcessMessages;
@@ -3178,10 +3173,11 @@ TIngrListItem = record
logo : TImage;
tbl : TBHRTable;
R : TRect;
LineSpace, wi, totbr : word;
{LineSpace,} wi, totbr : word;
totvol, x : double;
s : string;
Rec : TRecipe;

Procedure NextR;
begin
Inc(Ro);
@@ -3203,7 +3199,7 @@ TIngrListItem = record
Head2FontSize:= 13;
Head3FontSize:= 10;
TextFontSize:= 9;
LineSpace:= round(1.2 * FontSizeToPix(TextFontSize, 1));
//LineSpace:= round(1.2 * FontSizeToPix(TextFontSize, 1));
if (Doc <> NIL) then
begin
Screen.Cursor:= crHourglass;
18 changes: 10 additions & 8 deletions Source/Units/cloud.pas
Original file line number Diff line number Diff line change
@@ -883,7 +883,7 @@ implementation

Function TBHCloud.LoadRecipeByName(FN : string) : boolean;
var ftp: TFTPSend;
i, j, fnr : integer;
i : integer;
localfn, remotefn, remotefnd, ext : string;
bhr : TBHCloudFile;
begin
@@ -966,6 +966,7 @@ implementation

Function TBHCloud.LoadRecipeByIndex(i : longint) : boolean;
begin
Result:= True;
if (i >= Low(FFiles)) and (i <= High(FFiles)) then
LoadRecipeByName(FFiles[i].FileName.Value);
end;
@@ -1078,7 +1079,7 @@ function RunAsAdmin(const Handle: Hwnd; const Path, Params: string): Boolean;
var Proc: TProcess;
CharBuffer: array [0..511] of char;
RestCount: integer;
ExitCode: integer;
//ExitCode: integer;
SudoPassword: string;
begin
Result:= false;
@@ -1141,7 +1142,7 @@ function RunAsAdmin(const Handle: Hwnd; const Path, Params: string): Boolean;
end;
SudoPassword := 'password'; //hope this will scramble memory
SudoPassword := ''; // and make the program a bit safer from snooping?!?
ExitCode := Proc.ExitStatus;
//ExitCode := Proc.ExitStatus;
Result:= true;
finally
Proc.Free;
@@ -1229,12 +1230,11 @@ function RunAsAdmin(const Handle: Hwnd; const Path, Params: string): Boolean;

Function GetHTTPFile(URL, localfn : string) : boolean;
var Lines : TStringList;
Header : TStringList;
//Header : TStringList;
HTTPGetResult: boolean;
HTTPSender: THTTPSend;
RetryAttempt, i: integer;
RetryAttempt: integer;
dir : string;
s : string;
const MaxRetries = 1;
begin
result:= false;
@@ -1358,11 +1358,13 @@ function RunAsAdmin(const Handle: Hwnd; const Path, Params: string): Boolean;
end;

Function DownloadNewVersion(fn : string) : boolean;
var i, j : longint;
localfn, fnlocal, s, bs : string;
var localfn: string;
aProcess : TProcess; //TProcess is crossplatform is best way
delfile : PChar;
{$ifdef windows}
s, bs : string;
l : TStringList;
{$endif}
begin
Result:= false;
try
Loading