Commit 4e189dc

Nick Faro committed on
Fix silly crash when selecting header out of bounds
commit 4e189dc07b6d53b37ce0191a39d530d1a2197706 parent a7779ed
1 changed files +5−3
Modifiedsrc/tracker.pas +5−3
@@ -1689,6 +1689,7 @@ var
1689 SelectedSection: THeaderSection; 1689 SelectedSection: THeaderSection;
1690 P: TPoint; 1690 P: TPoint;
1691 I: Integer; 1691 I: Integer;
1692 SectionIndex: Integer;
1692 1693
1693 function OnlyOneSelected(Sct: Integer): Boolean; 1694 function OnlyOneSelected(Sct: Integer): Boolean;
1694 var 1695 var
@@ -1705,18 +1706,19 @@ begin
1705 1706
1706 P.X := X; 1707 P.X := X;
1707 P.Y := Y; 1708 P.Y := Y;
1709 SectionIndex := HeaderControl1.GetSectionAt(P);
1708 1710
1709 if HeaderControl1.GetSectionAt(P) = 0 then 1711 if (SectionIndex = 0) or (SectionIndex = -1) then
1710 Exit; 1712 Exit;
1711 1713
1712 if OnlyOneSelected(HeaderControl1.GetSectionAt(P)) then begin 1714 if OnlyOneSelected(SectionIndex) then begin
1713 for I := 1 to 4 do 1715 for I := 1 to 4 do
1714 HeaderControl1.Sections[I].ImageIndex := 1; 1716 HeaderControl1.Sections[I].ImageIndex := 1;
1715 end else begin 1717 end else begin
1716 for I := 1 to 4 do 1718 for I := 1 to 4 do
1717 HeaderControl1.Sections[I].ImageIndex := 0; 1719 HeaderControl1.Sections[I].ImageIndex := 0;
1718 1720
1719 SelectedSection := HeaderControl1.Sections[HeaderControl1.GetSectionAt(P)]; 1721 SelectedSection := HeaderControl1.Sections[SectionIndex];
1720 SelectedSection.ImageIndex := 1; 1722 SelectedSection.ImageIndex := 1;
1721 end; 1723 end;
1722 1724