Skip to content

Commit

Permalink
#75: Fixing a crash in GUI related to 0-width frames
Browse files Browse the repository at this point in the history
  • Loading branch information
bombomby committed Jul 12, 2019
1 parent c81a023 commit 213300d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion gui/Data/FrameCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,8 @@ public void Add(DataResponse response)

if (group.Board.MainThreadIndex == frame.Header.ThreadIndex)
{
Add(frame);
if (frame.Header.Duration > 0.0)
Add(frame);
}

break;
Expand Down
4 changes: 3 additions & 1 deletion gui/ThreadView/ThreadRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ public class ThreadScroll

public Durable ViewTime { get { return UnitToTime(ViewUnit); } }

public double Zoom { get { return 1.0 / ViewUnit.Width; } }

const double MIN_WIDTH = 0.000001;
public double Zoom { get { return 1.0 / Math.Max(MIN_WIDTH, ViewUnit.Width); } }

public double TimeToUnit(ITick tick)
{
Expand Down

1 comment on commit 213300d

@huangjunkun
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我建议同时在两个地方添加防护逻辑,提高程序健壮性:

1、ThreadView#DrawSelection
		for (int i = 0; i < SelectionBorderCount; ++i)
                    {
                        if (rect.IsEmpty)
                        {
                            break;
                        }
2、DynamicMesh#AddRect
            double width = (rect.Size.Width < 0) ? 0 : rect.Size.Width;
            double height = (rect.Size.Height < 0) ? 0 : rect.Size.Height;
            rect = new Rect(InverseLocalTransform.Transform(rect.Location), new Size(InverseLocalTransform.M11 * width, InverseLocalTransform.M22 * height));

Please sign in to comment.