← Back to team overview

kicad-developers team mailing list archive

[PATCH] Bugfix: EDA_RECT to BOX2I generated wrong boxes

 

Dear Kicad developers,

The "operator BOX2I() const" of EDA_RECT produced wrong boxes, usually
much to big. It passed its end-position as second argument to the
constructor of BOX2I. However, BOX2I expects its size as second
argument.

This caused a dramatic performance penalty in some
cases. Took me about a day to figure this out.

Cheers,
Andreas
>From 90f991e9938e0841908e58d665103e0f41fdbb43 Mon Sep 17 00:00:00 2001
From: Andreas Buhr <andreas@xxxxxxxxxxxxxx>
Date: Sun, 10 Dec 2017 23:04:23 +0100
Subject: [PATCH] Bugfix: EDA_RECT to BOX2I generated wrong boxes

The "operator BOX2I() const" of EDA_RECT produced
wrong boxes, usually much to big. It passed its
end-position as second argument to the constructor
of BOX2I. However, BOX2I expects its size as second
argument.

This caused a dramatic performance penalty in some
cases.
---
 include/class_eda_rect.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/class_eda_rect.h b/include/class_eda_rect.h
index 3062d0a..c6b0acf 100644
--- a/include/class_eda_rect.h
+++ b/include/class_eda_rect.h
@@ -227,7 +227,7 @@ public:
     {
         EDA_RECT rect( m_Pos, m_Size );
         rect.Normalize();
-        return BOX2I( rect.GetOrigin(), rect.GetEnd() );
+        return BOX2I( rect.GetOrigin(), rect.GetSize() );
     }
 
     /**
-- 
2.7.4


Follow ups