8263984: Invalidate printServices when there are no printers

Reviewed-by: serb, jdv
This commit is contained in:
Alexey Ivanov 2021-04-07 15:29:52 +00:00
parent adb860ec10
commit 9d6503978d

View file

@ -116,6 +116,7 @@ public class PrintServiceLookupProvider extends PrintServiceLookup {
if (printers == null) {
// In Windows it is safe to assume no default if printers == null so we
// don't get the default.
invalidateServices();
printServices = new PrintService[0];
return;
}
@ -146,16 +147,21 @@ public class PrintServiceLookupProvider extends PrintServiceLookup {
}
}
invalidateServices();
printServices = newServices;
}
private void invalidateServices() {
// Look for deleted services and invalidate these
if (printServices != null) {
for (int j=0; j < printServices.length; j++) {
if ((printServices[j] instanceof Win32PrintService) &&
(!printServices[j].equals(defaultPrintService))) {
((Win32PrintService)printServices[j]).invalidateService();
}
}
}
printServices = newServices;
}