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

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



The branch, master has been updated
       via  c2f52c71e6b199ae2196924b0d1cfd4fa8f23446 (commit)
      from  bc21ef592fc14e7ca9d483892473a522ff645368 (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/move.c |   45 +++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 43 insertions(+), 2 deletions(-)


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

commit c2f52c71e6b199ae2196924b0d1cfd4fa8f23446
Author: DJ Delorie <dj@xxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>

    Avoid top/bottom issues with layer deletion.
    
    PCB does not currently support boards without a top or bottom, so
    prevent the user from deleting them (they'd need to reassign the
    top/bottom groups first).

:100644 100644 de1e2e7... 3f902b8... M	src/move.c

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

commit c2f52c71e6b199ae2196924b0d1cfd4fa8f23446
Author: DJ Delorie <dj@xxxxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>

    Avoid top/bottom issues with layer deletion.
    
    PCB does not currently support boards without a top or bottom, so
    prevent the user from deleting them (they'd need to reassign the
    top/bottom groups first).

diff --git a/src/move.c b/src/move.c
index de1e2e7..3f902b8 100644
--- a/src/move.c
+++ b/src/move.c
@@ -912,6 +912,27 @@ move_all_thermals (int old_index, int new_index)
   ENDALL_LOOP;
 }
 
+static int
+LastLayerInComponentGroup (int layer)
+{
+  int cgroup = GetLayerGroupNumberByNumber(max_group + COMPONENT_LAYER);
+  int lgroup = GetLayerGroupNumberByNumber(layer);
+  if (cgroup == lgroup
+      && PCB->LayerGroups.Number[lgroup] == 2)
+    return 1;
+  return 0;
+}
+
+static int
+LastLayerInSolderGroup (int layer)
+{
+  int sgroup = GetLayerGroupNumberByNumber(max_group + SOLDER_LAYER);
+  int lgroup = GetLayerGroupNumberByNumber(layer);
+  if (sgroup == lgroup
+      && PCB->LayerGroups.Number[lgroup] == 2)
+    return 1;
+  return 0;
+}
 
 int
 MoveLayer (int old_index, int new_index)
@@ -938,6 +959,23 @@ MoveLayer (int old_index, int new_index)
   if (old_index == new_index)
     return 0;
 
+  if (new_index == -1
+      && LastLayerInComponentGroup (old_index))
+    {
+      gui->confirm_dialog ("You can't delete the last top-side layer\n", "Ok", NULL);
+      return 1;
+    }
+
+  if (new_index == -1
+      && LastLayerInSolderGroup (old_index))
+    {
+      gui->confirm_dialog ("You can't delete the last bottom-side layer\n", "Ok", NULL);
+      return 1;
+    }
+
+  for (g = 0; g < MAX_LAYER+2; g++)
+    groups[g] = -1;
+
   for (g = 0; g < MAX_LAYER; g++)
     for (l = 0; l < PCB->LayerGroups.Number[g]; l++)
       groups[PCB->LayerGroups.Entries[g][l]] = g;
@@ -1024,8 +1062,11 @@ MoveLayer (int old_index, int new_index)
     {
       int i;
       g = groups[l];
-      i = PCB->LayerGroups.Number[g]++;
-      PCB->LayerGroups.Entries[g][i] = l;
+      if (g >= 0)
+	{
+	  i = PCB->LayerGroups.Number[g]++;
+	  PCB->LayerGroups.Entries[g][i] = l;
+	}
     }
 
   for (g = 0; g < MAX_LAYER; g++)




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