[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: pcb.git: branch: master updated (cec4118b192773fccba226e1caf15ba401a1123d)



The branch, master has been updated
       via  cec4118b192773fccba226e1caf15ba401a1123d (commit)
       via  f0cc7b26a2c297fe2c79ac02450087861a6d63a1 (commit)
       via  1aac06b665330507ca42f380e38f32875a979cd9 (commit)
       via  d3b508ca272b7d89aa27f552ab78943f9bed27f9 (commit)
       via  b8c880c955859d2bc53079b4cafdf8914dafdec2 (commit)
       via  c80c2af6f06372e35d3fcf4115cd14220b3d16f6 (commit)
       via  efd212c1deb264e9a7f2be17e9338fbb60e22cc0 (commit)
      from  e8c699a6f7a954b31d400a5adb429105b0c24b15 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 src/action.c                     |   46 ++++++++++++++++++++++---------
 src/autoroute.c                  |    3 +-
 src/const.h                      |    1 +
 src/find.c                       |   55 +++++++++++++------------------------
 src/find.h                       |    7 +++--
 src/hid/gtk/gui-netlist-window.c |   11 +++-----
 src/hid/lesstif/netlist.c        |   11 +++-----
 src/rats.c                       |    9 ++----
 src/report.c                     |   21 +++++++-------
 src/select.c                     |   27 ++++++++++++++++++
 src/set.c                        |   10 +++---
 src/toporouter.c                 |    3 +-
 12 files changed, 112 insertions(+), 92 deletions(-)


=================
 Commit Messages
=================

commit cec4118b192773fccba226e1caf15ba401a1123d
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    Remove Draw() call from ResetFound*() Let the caller do it
    
    This allows multiple changes to be grouped into one repaint operation.
    Use this where appropriate, such as the Netlist lookup functions.

:100644 100644 c4c28c0... d8e631f... M	src/action.c
:100644 100644 345e670... f2f9a92... M	src/find.c
:100644 100644 07ff6b8... f0668d9... M	src/report.c
:100644 100644 c5d34eb... 25267d8... M	src/set.c

commit f0cc7b26a2c297fe2c79ac02450087861a6d63a1
Author: Martin Kupec <martin.kupec@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    Add NetByName to the select action options
    
    v2: Check Net name appropriately
    v3: Ensure we set the changed flag
    
    Reviewed-by: Peter Clifton <pcjc2@xxxxxxxxx>

:100644 100644 8e01180... c4c28c0... M	src/action.c
:100644 100644 676a6f0... e4a1d31... M	src/const.h
:100644 100644 87dc661... 27a590b... M	src/select.c

commit 1aac06b665330507ca42f380e38f32875a979cd9
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    find.c: Remove "undo" parameter to RatFindHook
    
    Since all callers pass false for the "undo" parameter since the
    last commit, remove it from the function prototype.
    
    NB: The file-global variable "User", which it previously set can be
    assumed to be false, as it defaults to false - and is restored after
    any code which temporarily sets it to true.

:100644 100644 519d0ba... 345e670... M	src/find.c
:100644 100644 892c7ef... 11f23e3... M	src/find.h
:100644 100644 e780aa4... 3d88554... M	src/hid/gtk/gui-netlist-window.c
:100644 100644 0bc4389... 906eda7... M	src/hid/lesstif/netlist.c
:100644 100644 3e9d6ee... 061f9aa... M	src/rats.c

commit d3b508ca272b7d89aa27f552ab78943f9bed27f9
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    We don't need the RatFindHook to save undo state when doing netlist lookup
    
    We already save undo information to get to a known state when
    resetting the FOUND flags. Since we later reset back to this state,
    we don't need to save undo data.

:100644 100644 ce3e2ff... e780aa4... M	src/hid/gtk/gui-netlist-window.c
:100644 100644 4ddc240... 0bc4389... M	src/hid/lesstif/netlist.c

commit b8c880c955859d2bc53079b4cafdf8914dafdec2
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    Fix netlist selection to save undo information for wiped "FOUND" flags
    
    When we wipe the found flags on objects, we should also queue them
    for redraw - this fixes that too, as the ResetConnections() argument
    controls both redraw AND saving undo data.

:100644 100644 addb0d0... ce3e2ff... M	src/hid/gtk/gui-netlist-window.c
:100644 100644 a2d3507... 4ddc240... M	src/hid/lesstif/netlist.c

commit c80c2af6f06372e35d3fcf4115cd14220b3d16f6
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    Remove unneeded Undo serial number save / restore in netlist lookup
    
    The RatFindHook function does not call anything which will increment
    the Undo serial number, so the save / restore calls are not required.

:100644 100644 96315b4... addb0d0... M	src/hid/gtk/gui-netlist-window.c
:100644 100644 bf48b09... a2d3507... M	src/hid/lesstif/netlist.c

commit efd212c1deb264e9a7f2be17e9338fbb60e22cc0
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    Fix broken undo handling for ResetFound*() and ResetConnections()
    
    Many callers have this idiom:
    
      SaveUndoSerialNumber ();
      ResetFoundPinsViasAndPads (AndDraw);
      RestoreUndoSerialNumber ();
      ResetFoundLinesAndPolygons (AndDraw);
    
    The intent is to squash the two operations into one undo operation. The
    ResetFound* functions DO increment the Undo serial number but ONLY if
    that particular function makes a change.
    
    Assume for the example that the first ResetFound* call makes some change
    and increments the serial number. This is then reset by the caller. If
    the second ResetFound* call doesn't find anything, there is no overall
    increment to the serial number.
    
    Move the undo serial number handling out of the ResetFound* calls, and
    let the callers increment the serial number if desired. To facilitate
    this, return a boolean value from these functions to indicate whether
    any changes were made which could be undone.
    
    For convenience, expose previously static find.c function
    ResetConnections() in order to avoid repeating Undo handling in each
    caller to the two ResetFound* functions which are often called together.

:100644 100644 7a9c3f0... 8e01180... M	src/action.c
:100644 100644 9ccab97... 976ef09... M	src/autoroute.c
:100644 100644 3176357... 519d0ba... M	src/find.c
:100644 100644 5b04980... 892c7ef... M	src/find.h
:100644 100644 cee63da... 96315b4... M	src/hid/gtk/gui-netlist-window.c
:100644 100644 3438b33... bf48b09... M	src/hid/lesstif/netlist.c
:100644 100644 5fe86cd... 3e9d6ee... M	src/rats.c
:100644 100644 a9c429d... 07ff6b8... M	src/report.c
:100644 100644 7a41f73... c5d34eb... M	src/set.c
:100644 100644 88c1325... bfd494a... M	src/toporouter.c

=========
 Changes
=========

commit cec4118b192773fccba226e1caf15ba401a1123d
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    Remove Draw() call from ResetFound*() Let the caller do it
    
    This allows multiple changes to be grouped into one repaint operation.
    Use this where appropriate, such as the Netlist lookup functions.

diff --git a/src/action.c b/src/action.c
index c4c28c0..d8e631f 100644
--- a/src/action.c
+++ b/src/action.c
@@ -2365,17 +2365,26 @@ ActionConnection (int argc, char **argv, int x, int y)
 
 	case F_ResetLinesAndPolygons:
 	  if (ResetFoundLinesAndPolygons (true))
-	    IncrementUndoSerialNumber ();
+	    {
+	      IncrementUndoSerialNumber ();
+	      Draw ();
+	    }
 	  break;
 
 	case F_ResetPinsViasAndPads:
 	  if (ResetFoundPinsViasAndPads (true))
-	    IncrementUndoSerialNumber ();
+	    {
+	      IncrementUndoSerialNumber ();
+	      Draw ();
+	    }
 	  break;
 
 	case F_Reset:
 	  if (ResetConnections (true))
-	    IncrementUndoSerialNumber ();
+	    {
+	      IncrementUndoSerialNumber ();
+	      Draw ();
+	    }
 	  break;
 	}
       RestoreCrosshair (true);
@@ -2789,7 +2798,10 @@ ActionDisplay (int argc, char **argv, int childX, int childY)
 	  if (TEST_FLAG (AUTODRCFLAG, PCB) && Settings.Mode == LINE_MODE)
 	    {
 	      if (ResetConnections (true))
-		IncrementUndoSerialNumber ();
+		{
+		  IncrementUndoSerialNumber ();
+		  Draw ();
+		}
 	      if (Crosshair.AttachedLine.State != STATE_FIRST)
 		LookupConnection (Crosshair.AttachedLine.Point1.X,
 				  Crosshair.AttachedLine.Point1.Y, true, 1,
diff --git a/src/find.c b/src/find.c
index 345e670..f2f9a92 100644
--- a/src/find.c
+++ b/src/find.c
@@ -3486,11 +3486,7 @@ ResetFoundPinsViasAndPads (bool AndDraw)
   }
   END_LOOP;
   if (change)
-    {
-      SetChangedFlag (true);
-      if (AndDraw)
-        Draw ();
-    }
+    SetChangedFlag (true);
   return change;
 }
 
@@ -3555,11 +3551,7 @@ ResetFoundLinesAndPolygons (bool AndDraw)
   }
   ENDALL_LOOP;
   if (change)
-    {
-      SetChangedFlag (true);
-      if (AndDraw)
-        Draw ();
-    }
+    SetChangedFlag (true);
   return change;
 }
 
@@ -3922,7 +3914,10 @@ DRCAll (void)
   TheFlag = FOUNDFLAG | DRCFLAG | SELECTEDFLAG;
 
   if (ResetConnections (true))
-    IncrementUndoSerialNumber ();
+    {
+      IncrementUndoSerialNumber ();
+      Draw ();
+    }
 
   User = false;
 
diff --git a/src/report.c b/src/report.c
index 07ff6b8..f0668d9 100644
--- a/src/report.c
+++ b/src/report.c
@@ -46,6 +46,7 @@
 #include "macro.h"
 #include "undo.h"
 #include "find.h"
+#include "draw.h"
 
 #ifdef HAVE_LIBDMALLOC
 #include <dmalloc.h>
@@ -688,7 +689,8 @@ ReportAllNetLengths (int argc, char **argv, int x, int y)
       continue;
 
     got_one:
-      ResetConnections (true);
+      if (ResetConnections (true))
+        Draw ();
       /* NB: XYtoNetLength calls LookupConnection, which performs an undo
        *     serial number update, so we don't need to add one here.
        */
@@ -706,7 +708,8 @@ ReportNetLength (int argc, char **argv, int x, int y)
   char *netname = 0;
   int found = 0;
 
-  ResetConnections (true);
+  if (ResetConnections (true))
+    Draw ();
   /* NB: XYtoNetLength calls LookupConnection, which performs an undo
    *     serial number update, so we don't need to add one here.
    */
diff --git a/src/set.c b/src/set.c
index c5d34eb..25267d8 100644
--- a/src/set.c
+++ b/src/set.c
@@ -293,7 +293,10 @@ SetMode (int Mode)
       if (Mode == LINE_MODE && TEST_FLAG (AUTODRCFLAG, PCB))
 	{
 	  if (ResetConnections (true))
-	    IncrementUndoSerialNumber ();
+	    {
+	      IncrementUndoSerialNumber ();
+	      Draw ();
+	    }
 	}
     }
 

commit f0cc7b26a2c297fe2c79ac02450087861a6d63a1
Author: Martin Kupec <martin.kupec@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    Add NetByName to the select action options
    
    v2: Check Net name appropriately
    v3: Ensure we set the changed flag
    
    Reviewed-by: Peter Clifton <pcjc2@xxxxxxxxx>

diff --git a/src/action.c b/src/action.c
index 8e01180..c4c28c0 100644
--- a/src/action.c
+++ b/src/action.c
@@ -135,6 +135,7 @@ typedef enum
   F_Move,
   F_NameOnPCB,
   F_Netlist,
+  F_NetByName,
   F_None,
   F_Notify,
   F_Object,
@@ -371,6 +372,7 @@ static FunctionType Functions[] = {
   {"Move", F_Move},
   {"NameOnPCB", F_NameOnPCB},
   {"Netlist", F_Netlist},
+  {"NetByName", F_NetByName},
   {"None", F_None},
   {"Notify", F_Notify},
   {"Object", F_Object},
@@ -5343,8 +5345,9 @@ static const char select_syntax[] =
   "Select(All|Block|Connection)\n"
   "Select(ElementByName|ObjectByName|PadByName|PinByName)\n"
   "Select(ElementByName|ObjectByName|PadByName|PinByName, Name)\n"
-  "Select(TextByName|ViaByName)\n"
-  "Select(TextByName|ViaByName, Name)\n" "Select(Convert)";
+  "Select(TextByName|ViaByName|NetByName)\n"
+  "Select(TextByName|ViaByName|NetByName, Name)\n"
+  "Select(Convert)";
 
 static const char select_help[] = "Toggles or sets the selection";
 
@@ -5358,6 +5361,7 @@ static const char select_help[] = "Toggles or sets the selection";
 @item PinByName
 @item TextByName
 @item ViaByName
+@item NetByName
 
 These all rely on having a regular expression parser built into
 @code{pcb}.  If the name is not specified then the user is prompted
@@ -5391,7 +5395,6 @@ ActionSelect (int argc, char **argv, int x, int y)
   char *function = ARG (0);
   if (function)
     {
-
       HideCrosshair (true);
       switch (GetFunctionID (function))
 	{
@@ -5416,6 +5419,9 @@ ActionSelect (int argc, char **argv, int x, int y)
 	case F_ViaByName:
 	  type = VIA_TYPE;
 	  goto commonByName;
+	case F_NetByName:
+	  type = NET_TYPE;
+	  goto commonByName;
 
 	commonByName:
 	  {
@@ -5573,7 +5579,6 @@ static int
 ActionUnselect (int argc, char **argv, int x, int y)
 {
   char *function = ARG (0);
-
   if (function)
     {
       HideCrosshair (true);
@@ -5600,6 +5605,9 @@ ActionUnselect (int argc, char **argv, int x, int y)
 	case F_ViaByName:
 	  type = VIA_TYPE;
 	  goto commonByName;
+	case F_NetByName:
+	  type = NET_TYPE;
+	  goto commonByName;
 
 	commonByName:
 	  {
diff --git a/src/const.h b/src/const.h
index 676a6f0..e4a1d31 100644
--- a/src/const.h
+++ b/src/const.h
@@ -310,6 +310,7 @@ When set, element names are not drawn.
 #define ELEMENTARC_TYPE		0x08000
 
 #define LOCKED_TYPE 		0x10000	/* used to tell search to include locked items. */
+#define NET_TYPE		0x20000 /* used to select whole net. */
 
 #define PIN_TYPES     (VIA_TYPE | PIN_TYPE)
 #define LOCK_TYPES    (VIA_TYPE | LINE_TYPE | ARC_TYPE | POLYGON_TYPE | ELEMENT_TYPE \
diff --git a/src/select.c b/src/select.c
index 87dc661..27a590b 100644
--- a/src/select.c
+++ b/src/select.c
@@ -44,6 +44,7 @@
 #include "undo.h"
 #include "rats.h"
 #include "misc.h"
+#include "find.h"
 
 #include <sys/types.h>
 #ifdef HAVE_REGEX_H
@@ -1011,6 +1012,32 @@ SelectObjectByName (int Type, char *Pattern, bool Flag)
       }
   }
   END_LOOP;
+  if (Type & NET_TYPE)
+    {
+      InitConnectionLookup ();
+      changed = ResetConnections (true) || changed;
+
+      MENU_LOOP (&PCB->NetlistLib);
+      {
+        Cardinal i;
+        LibraryEntryType *entry;
+        ConnectionType conn;
+
+        /* Name[0] and Name[1] are special purpose, not the actual name*/
+        if (menu->Name && menu->Name[0] != '\0' && menu->Name[1] != '\0' &&
+            REGEXEC (menu->Name + 2))
+          {
+            for (i = menu->EntryN, entry = menu->Entry; i; i--, entry++)
+              if (SeekPad (entry, &conn, false))
+                RatFindHook (conn.type, conn.ptr1, conn.ptr2, conn.ptr2, true);
+          }
+      }
+      END_LOOP;
+
+      changed = SelectConnection (Flag) || changed;
+      changed = ResetConnections (false) || changed;
+      FreeConnectionLookupMemory ();
+    }
 
 #if defined(HAVE_REGCOMP)
 #if !defined(sgi)

commit 1aac06b665330507ca42f380e38f32875a979cd9
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    find.c: Remove "undo" parameter to RatFindHook
    
    Since all callers pass false for the "undo" parameter since the
    last commit, remove it from the function prototype.
    
    NB: The file-global variable "User", which it previously set can be
    assumed to be false, as it defaults to false - and is restored after
    any code which temporarily sets it to true.

diff --git a/src/find.c b/src/find.c
index 519d0ba..345e670 100644
--- a/src/find.c
+++ b/src/find.c
@@ -3398,15 +3398,11 @@ LookupConnection (LocationType X, LocationType Y, bool AndDraw,
  * assumes InitConnectionLookup() has already been done
  */
 void
-  RatFindHook
-  (int type, void *ptr1, void *ptr2, void *ptr3, bool undo,
-   bool AndRats)
+RatFindHook (int type, void *ptr1, void *ptr2, void *ptr3, bool AndRats)
 {
-  User = undo;
   DumpList ();
   ListStart (type, ptr1, ptr2, ptr3);
   DoIt (AndRats, false);
-  User = false;
 }
 
 /* ---------------------------------------------------------------------------
diff --git a/src/find.h b/src/find.h
index 892c7ef..11f23e3 100644
--- a/src/find.h
+++ b/src/find.h
@@ -63,7 +63,7 @@ void InitLayoutLookup (void);
 void FreeConnectionLookupMemory (void);
 void FreeComponentLookupMemory (void);
 void FreeLayoutLookupMemory (void);
-void RatFindHook (int, void *, void *, void *, bool, bool);
+void RatFindHook (int, void *, void *, void *, bool);
 void SaveFindFlag (int);
 void RestoreFindFlag (void);
 int DRCAll (void);
diff --git a/src/hid/gtk/gui-netlist-window.c b/src/hid/gtk/gui-netlist-window.c
index e780aa4..3d88554 100644
--- a/src/hid/gtk/gui-netlist-window.c
+++ b/src/hid/gtk/gui-netlist-window.c
@@ -520,7 +520,7 @@ netlist_select_cb (GtkWidget * widget, gpointer data)
 
   for (i = selected_net->EntryN, entry = selected_net->Entry; i; i--, entry++)
     if (SeekPad (entry, &conn, false))
-      RatFindHook (conn.type, conn.ptr1, conn.ptr2, conn.ptr2, false, true);
+      RatFindHook (conn.type, conn.ptr1, conn.ptr2, conn.ptr2, true);
 
   SelectConnection (select_flag);
   ResetConnections (false);
diff --git a/src/hid/lesstif/netlist.c b/src/hid/lesstif/netlist.c
index 0bc4389..906eda7 100644
--- a/src/hid/lesstif/netlist.c
+++ b/src/hid/lesstif/netlist.c
@@ -140,7 +140,7 @@ nbcb_select_common (LibraryMenuTypePtr net, int pos, int select_flag)
 
   for (i = net->EntryN, entry = net->Entry; i; i--, entry++)
     if (SeekPad (entry, &conn, false))
-      RatFindHook (conn.type, conn.ptr1, conn.ptr2, conn.ptr2, false, true);
+      RatFindHook (conn.type, conn.ptr1, conn.ptr2, conn.ptr2, true);
 
   SelectConnection (select_flag);
   ResetConncetions (false);
diff --git a/src/rats.c b/src/rats.c
index 3e9d6ee..061f9aa 100644
--- a/src/rats.c
+++ b/src/rats.c
@@ -465,8 +465,7 @@ GatherSubnets (NetListTypePtr Netl, bool NoWarn, bool AndRats)
       a = &Netl->Net[m];
       ResetConnections (false);
       RatFindHook (a->Connection[0].type, a->Connection[0].ptr1,
-		   a->Connection[0].ptr2, a->Connection[0].ptr2, false,
-		   AndRats);
+		   a->Connection[0].ptr2, a->Connection[0].ptr2, AndRats);
       /* now anybody connected to the first point has DRCFLAG set */
       /* so move those to this subnet */
       CLEAR_FLAG (DRCFLAG, (PinTypePtr) a->Connection[0].ptr2);

commit d3b508ca272b7d89aa27f552ab78943f9bed27f9
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    We don't need the RatFindHook to save undo state when doing netlist lookup
    
    We already save undo information to get to a known state when
    resetting the FOUND flags. Since we later reset back to this state,
    we don't need to save undo data.

diff --git a/src/hid/gtk/gui-netlist-window.c b/src/hid/gtk/gui-netlist-window.c
index ce3e2ff..e780aa4 100644
--- a/src/hid/gtk/gui-netlist-window.c
+++ b/src/hid/gtk/gui-netlist-window.c
@@ -520,7 +520,7 @@ netlist_select_cb (GtkWidget * widget, gpointer data)
 
   for (i = selected_net->EntryN, entry = selected_net->Entry; i; i--, entry++)
     if (SeekPad (entry, &conn, false))
-      RatFindHook (conn.type, conn.ptr1, conn.ptr2, conn.ptr2, true, true);
+      RatFindHook (conn.type, conn.ptr1, conn.ptr2, conn.ptr2, false, true);
 
   SelectConnection (select_flag);
   ResetConnections (false);
diff --git a/src/hid/lesstif/netlist.c b/src/hid/lesstif/netlist.c
index 4ddc240..0bc4389 100644
--- a/src/hid/lesstif/netlist.c
+++ b/src/hid/lesstif/netlist.c
@@ -140,7 +140,7 @@ nbcb_select_common (LibraryMenuTypePtr net, int pos, int select_flag)
 
   for (i = net->EntryN, entry = net->Entry; i; i--, entry++)
     if (SeekPad (entry, &conn, false))
-      RatFindHook (conn.type, conn.ptr1, conn.ptr2, conn.ptr2, true, true);
+      RatFindHook (conn.type, conn.ptr1, conn.ptr2, conn.ptr2, false, true);
 
   SelectConnection (select_flag);
   ResetConncetions (false);

commit b8c880c955859d2bc53079b4cafdf8914dafdec2
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    Fix netlist selection to save undo information for wiped "FOUND" flags
    
    When we wipe the found flags on objects, we should also queue them
    for redraw - this fixes that too, as the ResetConnections() argument
    controls both redraw AND saving undo data.

diff --git a/src/hid/gtk/gui-netlist-window.c b/src/hid/gtk/gui-netlist-window.c
index addb0d0..ce3e2ff 100644
--- a/src/hid/gtk/gui-netlist-window.c
+++ b/src/hid/gtk/gui-netlist-window.c
@@ -516,7 +516,7 @@ netlist_select_cb (GtkWidget * widget, gpointer data)
     node_selected_net = NULL;
 
   InitConnectionLookup ();
-  ResetConnections (false);
+  ResetConnections (true);
 
   for (i = selected_net->EntryN, entry = selected_net->Entry; i; i--, entry++)
     if (SeekPad (entry, &conn, false))
diff --git a/src/hid/lesstif/netlist.c b/src/hid/lesstif/netlist.c
index a2d3507..4ddc240 100644
--- a/src/hid/lesstif/netlist.c
+++ b/src/hid/lesstif/netlist.c
@@ -136,7 +136,7 @@ nbcb_select_common (LibraryMenuTypePtr net, int pos, int select_flag)
   int i;
 
   InitConnectionLookup ();
-  ResetConnections (false);
+  ResetConnections (true);
 
   for (i = net->EntryN, entry = net->Entry; i; i--, entry++)
     if (SeekPad (entry, &conn, false))

commit c80c2af6f06372e35d3fcf4115cd14220b3d16f6
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    Remove unneeded Undo serial number save / restore in netlist lookup
    
    The RatFindHook function does not call anything which will increment
    the Undo serial number, so the save / restore calls are not required.

diff --git a/src/hid/gtk/gui-netlist-window.c b/src/hid/gtk/gui-netlist-window.c
index 96315b4..addb0d0 100644
--- a/src/hid/gtk/gui-netlist-window.c
+++ b/src/hid/gtk/gui-netlist-window.c
@@ -518,11 +518,9 @@ netlist_select_cb (GtkWidget * widget, gpointer data)
   InitConnectionLookup ();
   ResetConnections (false);
 
-  SaveUndoSerialNumber ();
   for (i = selected_net->EntryN, entry = selected_net->Entry; i; i--, entry++)
     if (SeekPad (entry, &conn, false))
       RatFindHook (conn.type, conn.ptr1, conn.ptr2, conn.ptr2, true, true);
-  RestoreUndoSerialNumber ();
 
   SelectConnection (select_flag);
   ResetConnections (false);
diff --git a/src/hid/lesstif/netlist.c b/src/hid/lesstif/netlist.c
index bf48b09..a2d3507 100644
--- a/src/hid/lesstif/netlist.c
+++ b/src/hid/lesstif/netlist.c
@@ -138,11 +138,9 @@ nbcb_select_common (LibraryMenuTypePtr net, int pos, int select_flag)
   InitConnectionLookup ();
   ResetConnections (false);
 
-  SaveUndoSerialNumber ();
   for (i = net->EntryN, entry = net->Entry; i; i--, entry++)
     if (SeekPad (entry, &conn, false))
       RatFindHook (conn.type, conn.ptr1, conn.ptr2, conn.ptr2, true, true);
-  RestoreUndoSerialNumber ();
 
   SelectConnection (select_flag);
   ResetConncetions (false);

commit efd212c1deb264e9a7f2be17e9338fbb60e22cc0
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    Fix broken undo handling for ResetFound*() and ResetConnections()
    
    Many callers have this idiom:
    
      SaveUndoSerialNumber ();
      ResetFoundPinsViasAndPads (AndDraw);
      RestoreUndoSerialNumber ();
      ResetFoundLinesAndPolygons (AndDraw);
    
    The intent is to squash the two operations into one undo operation. The
    ResetFound* functions DO increment the Undo serial number but ONLY if
    that particular function makes a change.
    
    Assume for the example that the first ResetFound* call makes some change
    and increments the serial number. This is then reset by the caller. If
    the second ResetFound* call doesn't find anything, there is no overall
    increment to the serial number.
    
    Move the undo serial number handling out of the ResetFound* calls, and
    let the callers increment the serial number if desired. To facilitate
    this, return a boolean value from these functions to indicate whether
    any changes were made which could be undone.
    
    For convenience, expose previously static find.c function
    ResetConnections() in order to avoid repeating Undo handling in each
    caller to the two ResetFound* functions which are often called together.

diff --git a/src/action.c b/src/action.c
index 7a9c3f0..8e01180 100644
--- a/src/action.c
+++ b/src/action.c
@@ -2362,18 +2362,18 @@ ActionConnection (int argc, char **argv, int x, int y)
 	  }
 
 	case F_ResetLinesAndPolygons:
-	  ResetFoundLinesAndPolygons (true);
+	  if (ResetFoundLinesAndPolygons (true))
+	    IncrementUndoSerialNumber ();
 	  break;
 
 	case F_ResetPinsViasAndPads:
-	  ResetFoundPinsViasAndPads (true);
+	  if (ResetFoundPinsViasAndPads (true))
+	    IncrementUndoSerialNumber ();
 	  break;
 
 	case F_Reset:
-	  SaveUndoSerialNumber ();
-	  ResetFoundPinsViasAndPads (true);
-	  RestoreUndoSerialNumber ();
-	  ResetFoundLinesAndPolygons (true);
+	  if (ResetConnections (true))
+	    IncrementUndoSerialNumber ();
 	  break;
 	}
       RestoreCrosshair (true);
@@ -2786,10 +2786,8 @@ ActionDisplay (int argc, char **argv, int childX, int childY)
 	  TOGGLE_FLAG (AUTODRCFLAG, PCB);
 	  if (TEST_FLAG (AUTODRCFLAG, PCB) && Settings.Mode == LINE_MODE)
 	    {
-	      SaveUndoSerialNumber ();
-	      ResetFoundPinsViasAndPads (true);
-	      RestoreUndoSerialNumber ();
-	      ResetFoundLinesAndPolygons (true);
+	      if (ResetConnections (true))
+		IncrementUndoSerialNumber ();
 	      if (Crosshair.AttachedLine.State != STATE_FIRST)
 		LookupConnection (Crosshair.AttachedLine.Point1.X,
 				  Crosshair.AttachedLine.Point1.Y, true, 1,
diff --git a/src/autoroute.c b/src/autoroute.c
index 9ccab97..976ef09 100644
--- a/src/autoroute.c
+++ b/src/autoroute.c
@@ -985,8 +985,7 @@ CreateRouteData ()
    * this saves on searching the trees to find the nets
    */
   /* use the DRCFLAG to mark objects as they are entered */
-  ResetFoundPinsViasAndPads (false);
-  ResetFoundLinesAndPolygons (false);
+  ResetConnections (false);
   Nets = CollectSubnets (false);
   {
     routebox_t *last_net = NULL;
diff --git a/src/find.c b/src/find.c
index 3176357..519d0ba 100644
--- a/src/find.c
+++ b/src/find.c
@@ -345,7 +345,6 @@ static void PrintPinConnections (FILE *, bool);
 static bool PrintAndSelectUnusedPinsAndPadsOfElement (ElementTypePtr,
                                                          FILE *);
 static void DrawNewConnections (void);
-static void ResetConnections (bool);
 static void DumpList (void);
 static void LocateError (LocationType *, LocationType *);
 static void BuildObjectList (int *, long int **, int **);
@@ -3418,9 +3417,7 @@ LookupUnusedPins (FILE * FP)
 {
   /* reset all currently marked connections */
   User = true;
-  SaveUndoSerialNumber ();
   ResetConnections (true);
-  RestoreUndoSerialNumber ();
   InitConnectionLookup ();
 
   ELEMENT_LOOP (PCB->Data);
@@ -3444,12 +3441,11 @@ LookupUnusedPins (FILE * FP)
 /* ---------------------------------------------------------------------------
  * resets all used flags of pins and vias
  */
-void
+bool
 ResetFoundPinsViasAndPads (bool AndDraw)
 {
   bool change = false;
 
-
   VIA_LOOP (PCB->Data);
   {
     if (TEST_FLAG (TheFlag, via))
@@ -3497,22 +3493,19 @@ ResetFoundPinsViasAndPads (bool AndDraw)
     {
       SetChangedFlag (true);
       if (AndDraw)
-        {
-          IncrementUndoSerialNumber ();
-          Draw ();
-        }
+        Draw ();
     }
+  return change;
 }
 
 /* ---------------------------------------------------------------------------
  * resets all used flags of LOs
  */
-void
+bool
 ResetFoundLinesAndPolygons (bool AndDraw)
 {
   bool change = false;
 
-
   RAT_LOOP (PCB->Data);
   {
     if (TEST_FLAG (TheFlag, line))
@@ -3569,25 +3562,23 @@ ResetFoundLinesAndPolygons (bool AndDraw)
     {
       SetChangedFlag (true);
       if (AndDraw)
-        {
-          IncrementUndoSerialNumber ();
-          Draw ();
-        }
+        Draw ();
     }
+  return change;
 }
 
 /* ---------------------------------------------------------------------------
  * resets all found connections
  */
-static void
+bool
 ResetConnections (bool AndDraw)
 {
-  if (AndDraw)
-    SaveUndoSerialNumber ();
-  ResetFoundPinsViasAndPads (AndDraw);
-  if (AndDraw)
-    RestoreUndoSerialNumber ();
-  ResetFoundLinesAndPolygons (AndDraw);
+  bool change = false;
+
+  change = ResetFoundPinsViasAndPads  (AndDraw) || change;
+  change = ResetFoundLinesAndPolygons (AndDraw) || change;
+
+  return change;
 }
 
 /*----------------------------------------------------------------------------
@@ -3934,7 +3925,8 @@ DRCAll (void)
 
   TheFlag = FOUNDFLAG | DRCFLAG | SELECTEDFLAG;
 
-  ResetConnections (true);
+  if (ResetConnections (true))
+    IncrementUndoSerialNumber ();
 
   User = false;
 
diff --git a/src/find.h b/src/find.h
index 5b04980..892c7ef 100644
--- a/src/find.h
+++ b/src/find.h
@@ -54,8 +54,9 @@ void LookupElementConnections (ElementTypePtr, FILE *);
 void LookupConnectionsToAllElements (FILE *);
 void LookupConnection (LocationType, LocationType, bool, BDimension, int);
 void LookupUnusedPins (FILE *);
-void ResetFoundLinesAndPolygons (bool);
-void ResetFoundPinsViasAndPads (bool);
+bool ResetFoundLinesAndPolygons (bool);
+bool ResetFoundPinsViasAndPads (bool);
+bool ResetConnections (bool);
 void InitConnectionLookup (void);
 void InitComponentLookup (void);
 void InitLayoutLookup (void);
diff --git a/src/hid/gtk/gui-netlist-window.c b/src/hid/gtk/gui-netlist-window.c
index cee63da..96315b4 100644
--- a/src/hid/gtk/gui-netlist-window.c
+++ b/src/hid/gtk/gui-netlist-window.c
@@ -516,17 +516,16 @@ netlist_select_cb (GtkWidget * widget, gpointer data)
     node_selected_net = NULL;
 
   InitConnectionLookup ();
-  ResetFoundPinsViasAndPads (false);
-  ResetFoundLinesAndPolygons (false);
-  SaveUndoSerialNumber ();
+  ResetConnections (false);
 
+  SaveUndoSerialNumber ();
   for (i = selected_net->EntryN, entry = selected_net->Entry; i; i--, entry++)
     if (SeekPad (entry, &conn, false))
       RatFindHook (conn.type, conn.ptr1, conn.ptr2, conn.ptr2, true, true);
   RestoreUndoSerialNumber ();
+
   SelectConnection (select_flag);
-  ResetFoundPinsViasAndPads (false);
-  ResetFoundLinesAndPolygons (false);
+  ResetConnections (false);
   FreeConnectionLookupMemory ();
   IncrementUndoSerialNumber ();
   Draw ();
diff --git a/src/hid/lesstif/netlist.c b/src/hid/lesstif/netlist.c
index 3438b33..bf48b09 100644
--- a/src/hid/lesstif/netlist.c
+++ b/src/hid/lesstif/netlist.c
@@ -136,17 +136,16 @@ nbcb_select_common (LibraryMenuTypePtr net, int pos, int select_flag)
   int i;
 
   InitConnectionLookup ();
-  ResetFoundPinsViasAndPads (false);
-  ResetFoundLinesAndPolygons (false);
-  SaveUndoSerialNumber ();
+  ResetConnections (false);
 
+  SaveUndoSerialNumber ();
   for (i = net->EntryN, entry = net->Entry; i; i--, entry++)
     if (SeekPad (entry, &conn, false))
       RatFindHook (conn.type, conn.ptr1, conn.ptr2, conn.ptr2, true, true);
   RestoreUndoSerialNumber ();
+
   SelectConnection (select_flag);
-  ResetFoundPinsViasAndPads (false);
-  ResetFoundLinesAndPolygons (false);
+  ResetConncetions (false);
   FreeConnectionLookupMemory ();
   IncrementUndoSerialNumber ();
   Draw ();
diff --git a/src/rats.c b/src/rats.c
index 5fe86cd..3e9d6ee 100644
--- a/src/rats.c
+++ b/src/rats.c
@@ -463,8 +463,7 @@ GatherSubnets (NetListTypePtr Netl, bool NoWarn, bool AndRats)
   for (m = 0; Netl->NetN > 0 && m < Netl->NetN; m++)
     {
       a = &Netl->Net[m];
-      ResetFoundPinsViasAndPads (false);
-      ResetFoundLinesAndPolygons (false);
+      ResetConnections (false);
       RatFindHook (a->Connection[0].type, a->Connection[0].ptr1,
 		   a->Connection[0].ptr2, a->Connection[0].ptr2, false,
 		   AndRats);
@@ -545,8 +544,7 @@ GatherSubnets (NetListTypePtr Netl, bool NoWarn, bool AndRats)
       if (!NoWarn)
 	Warned |= CheckShorts (a->Connection[0].menu);
     }
-  ResetFoundPinsViasAndPads (false);
-  ResetFoundLinesAndPolygons (false);
+  ResetConnections (false);
   return (Warned);
 }
 
diff --git a/src/report.c b/src/report.c
index a9c429d..07ff6b8 100644
--- a/src/report.c
+++ b/src/report.c
@@ -688,11 +688,10 @@ ReportAllNetLengths (int argc, char **argv, int x, int y)
       continue;
 
     got_one:
-      SaveUndoSerialNumber ();
-      ResetFoundPinsViasAndPads (true);
-      RestoreUndoSerialNumber ();
-      ResetFoundLinesAndPolygons (true);
-      RestoreUndoSerialNumber ();
+      ResetConnections (true);
+      /* NB: XYtoNetLength calls LookupConnection, which performs an undo
+       *     serial number update, so we don't need to add one here.
+       */
       length = XYtoNetLength (x, y, &found);
 
       gui->log("Net %s length %.*f %s\n", netname, prec, length*scale, units_name);
@@ -707,11 +706,10 @@ ReportNetLength (int argc, char **argv, int x, int y)
   char *netname = 0;
   int found = 0;
 
-  SaveUndoSerialNumber ();
-  ResetFoundPinsViasAndPads (true);
-  RestoreUndoSerialNumber ();
-  ResetFoundLinesAndPolygons (true);
-  RestoreUndoSerialNumber ();
+  ResetConnections (true);
+  /* NB: XYtoNetLength calls LookupConnection, which performs an undo
+   *     serial number update, so we don't need to add one here.
+   */
   gui->get_coords ("Click on a connection", &x, &y);
 
   length = XYtoNetLength (x, y, &found);
diff --git a/src/set.c b/src/set.c
index 7a41f73..c5d34eb 100644
--- a/src/set.c
+++ b/src/set.c
@@ -292,11 +292,8 @@ SetMode (int Mode)
       Crosshair.AttachedLine.State = STATE_FIRST;
       if (Mode == LINE_MODE && TEST_FLAG (AUTODRCFLAG, PCB))
 	{
-	  SaveUndoSerialNumber ();
-	  ResetFoundPinsViasAndPads (true);
-	  RestoreUndoSerialNumber ();
-	  ResetFoundLinesAndPolygons (true);
-	  IncrementUndoSerialNumber ();
+	  if (ResetConnections (true))
+	    IncrementUndoSerialNumber ();
 	}
     }
 
diff --git a/src/toporouter.c b/src/toporouter.c
index 88c1325..bfd494a 100644
--- a/src/toporouter.c
+++ b/src/toporouter.c
@@ -2799,8 +2799,7 @@ void
 import_clusters(toporouter_t *r)
 {
   NetListListType nets;
-  ResetFoundPinsViasAndPads (false);
-  ResetFoundLinesAndPolygons (false);
+  ResetConnections (false);
   nets = CollectSubnets(false);
   NETLIST_LOOP(&nets);
   {




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs