Dan McMahill wrote:
Daniel Wisehart wrote:

If I start adding line segments to the rat lines layer, and after adding a segment or two but still in the middle of the command, I type a 'u', PCB core dumps. The problem is that SearchObjectByLocation() is failing to find anything.

Here is a patch that keeps PCB from core dumping, but I think that SearchObjectByLocation() probably needs looking at.

Regards,
Daniel


The reason SearchObjectByLocation is failing is we need to search for RATLINE_TYPE as well:



--- action.c    12 Apr 2006 22:51:02 -0000      1.81
+++ action.c    28 Apr 2006 23:32:04 -0000
@@ -5391,5 +5391,5 @@
              LineTypePtr ptr2;
              /* this search is guranteed to succeed */
-             SearchObjectByLocation (LINE_TYPE, &ptr1, &ptrtmp,
+ SearchObjectByLocation (LINE_TYPE | RATLINE_TYPE, &ptr1, &ptrtmp, &ptr3, Crosshair.AttachedLine.Point1.X,
                                      Crosshair.AttachedLine.Point1.Y, 0);


This almost fixes it. I can add a bunch of ratline segments. I hit 'u' and each time I do that, it undoes the last segment. This works all the way up until I just have the initial point. One more 'u' and I segfault again. I think the problem there is I should not be in this section of code (Crosshair.AttachedLine.State == STATE_THIRD) anymore. So, I'll keep looking.

-Dan

oh, duh... If I'd kept reading the code I would have seen a few more spots a few lines down where RATLINE_TYPE needed to be or-ed in. And also it looks like we weren't quite keeping track of the number of added line segments.

Try the attached patch.

-Dan



Index: action.c
===================================================================
RCS file: /cvsroot/pcb/pcb/src/action.c,v
retrieving revision 1.81
diff -u -2 -r1.81 action.c
--- action.c    12 Apr 2006 22:51:02 -0000      1.81
+++ action.c    28 Apr 2006 23:43:14 -0000
@@ -1128,4 +1128,5 @@
          if ((line = AddNet ()))
            {
+             addedLines++;
              AddObjectToCreateUndoList (RATLINE_TYPE, line, line, line);
              IncrementUndoSerialNumber ();
@@ -5391,5 +5392,5 @@
              LineTypePtr ptr2;
              /* this search is guranteed to succeed */
-             SearchObjectByLocation (LINE_TYPE, &ptr1, &ptrtmp,
+             SearchObjectByLocation (LINE_TYPE | RATLINE_TYPE, &ptr1, &ptrtmp,
                                      &ptr3, Crosshair.AttachedLine.Point1.X,
                                      Crosshair.AttachedLine.Point1.Y, 0);
@@ -5421,5 +5422,6 @@
                {
                  /* this search should find the restored line */
-                 SearchObjectByLocation (LINE_TYPE, &ptr1, &ptrtmp,
+                 SearchObjectByLocation (LINE_TYPE | RATLINE_TYPE, &ptr1, 
+                                         &ptrtmp,
                                          &ptr3,
                                          Crosshair.AttachedLine.Point2.X,
@@ -5441,5 +5443,6 @@
                {
                  /* this search is guranteed to succeed too */
-                 SearchObjectByLocation (LINE_TYPE, &ptr1, &ptrtmp,
+                 SearchObjectByLocation (LINE_TYPE | RATLINE_TYPE, &ptr1, 
+                                         &ptrtmp,
                                          &ptr3,
                                          Crosshair.AttachedLine.Point1.X,

Reply via email to