]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Prevent recursion between DeletePrinterFromClasses(),
authorandy <andy@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 15 Mar 2001 20:00:57 +0000 (20:00 +0000)
committerandy <andy@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 15 Mar 2001 20:00:57 +0000 (20:00 +0000)
DeletePrinterFromClass(), and DeletePrinter().

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@1635 7a7537e8-13f0-0310-91df-b6672ffda945

scheduler/classes.c
scheduler/printers.c

index eaab1ebe695d9737833ce7dc833b85c22cff4945..81964c9eb290fb230ad8df88cc3a8bc16e4fbefd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: classes.c,v 1.33 2001/03/15 19:26:22 andy Exp $"
+ * "$Id: classes.c,v 1.34 2001/03/15 20:00:57 andy Exp $"
  *
  *   Printer class routines for the Common UNIX Printing System (CUPS).
  *
@@ -165,32 +165,25 @@ DeletePrinterFromClass(printer_t *c,      /* I - Class to delete from */
   }
 
  /*
-  * If there are no more printers in this class, delete the class...
+  * Recompute the printer type mask as needed...
   */
 
-  if (c->num_printers == 0)
+  if (c->num_printers > 0)
   {
-    DeletePrinter(c);
-    return;
-  }
-
- /*
-  * Recompute the printer type mask...
-  */
-
-  type    = c->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT);
-  c->type = ~CUPS_PRINTER_REMOTE;
+    type    = c->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT);
+    c->type = ~CUPS_PRINTER_REMOTE;
 
-  for (i = 0; i < c->num_printers; i ++)
-    c->type &= c->printers[i]->type;
+    for (i = 0; i < c->num_printers; i ++)
+      c->type &= c->printers[i]->type;
 
-  c->type |= type;
+    c->type |= type;
 
- /*
-  * Update the IPP attributes...
-  */
  /*
+    * Update the IPP attributes...
+    */
 
-  SetPrinterAttrs(c);
+    SetPrinterAttrs(c);
+  }
 }
 
 
@@ -202,7 +195,6 @@ void
 DeletePrinterFromClasses(printer_t *p) /* I - Printer to delete */
 {
   printer_t    *c,                     /* Pointer to current class */
-               *prev,
                *next;                  /* Pointer to next class */
 
 
@@ -211,13 +203,26 @@ DeletePrinterFromClasses(printer_t *p)    /* I - Printer to delete */
   * from each class listed...
   */
 
-  for (c = Printers, prev = NULL; c != NULL; prev = c, c = next)
+  for (c = Printers; c != NULL; c = next)
   {
     next = c->next;
 
     if (c->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT))
       DeletePrinterFromClass(c, p);
   }
+
+ /*
+  * Then clean out any empty classes...
+  */
+
+  for (c = Printers; c != NULL; c = next)
+  {
+    next = c->next;
+
+    if ((c->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT)) &&
+        c->num_printers == 0)
+      DeletePrinter(c);
+  }
 }
 
 
@@ -625,5 +630,5 @@ SaveAllClasses(void)
 
 
 /*
- * End of "$Id: classes.c,v 1.33 2001/03/15 19:26:22 andy Exp $".
+ * End of "$Id: classes.c,v 1.34 2001/03/15 20:00:57 andy Exp $".
  */
index b20f926cce213c9fa2ba8bdac6f7d9f5629e6556..56615285d49fe7fbb834dc5ad0ea2cc3298e1824 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: printers.c,v 1.91 2001/03/15 19:26:23 andy Exp $"
+ * "$Id: printers.c,v 1.92 2001/03/15 20:00:57 andy Exp $"
  *
  *   Printer routines for the Common UNIX Printing System (CUPS).
  *
@@ -330,7 +330,8 @@ DeletePrinter(printer_t *p) /* I - Printer to delete */
   * Remove this printer from any classes...
   */
 
-  DeletePrinterFromClasses(p);
+  if (!(p->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT)))
+    DeletePrinterFromClasses(p);
 
  /*
   * Free all memory used by the printer...
@@ -1781,5 +1782,5 @@ write_printcap(void)
 
 
 /*
- * End of "$Id: printers.c,v 1.91 2001/03/15 19:26:23 andy Exp $".
+ * End of "$Id: printers.c,v 1.92 2001/03/15 20:00:57 andy Exp $".
  */