Skip to content

Commit

Permalink
8263984: Invalidate printServices when there are no printers
Browse files Browse the repository at this point in the history
Reviewed-by: serb, jdv
  • Loading branch information
aivanov-jdk committed Apr 7, 2021
1 parent adb860e commit 9d65039
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -116,6 +116,7 @@ private synchronized void refreshServices() {
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;
}
Expand Down Expand Up @@ -146,16 +147,21 @@ private synchronized void refreshServices() {
}
}

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;
}


Expand Down

1 comment on commit 9d65039

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.