Skip to content

Commit

Permalink
Simpler fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Vzor- committed Apr 27, 2024
1 parent b491f2e commit 54f1871
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/qz/printer/info/NativePrinterMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ public ArrayList<PrintService> findMissing(boolean exhaustive, PrintService[] se
ArrayList<PrintService> serviceList = new ArrayList<>(Arrays.asList(services)); // shrinking list drastically improves performance

for(NativePrinter printer : values()) {
if (serviceList.contains(printer.getPrintService())) {
int index = serviceList.indexOf(printer.getPrintService());
if (index >= 0) {
// Java's `PrintService.equals(o)` method uses getName().equals(). This causes issues if a stale PrintService has been replaced
// by a new PrintService of the same name. For that reason, we always refresh the PrintService reference in NativePrinter.
// See: https://github.com/qzind/tray/issues/1259
printer.setPrintService(serviceList.get(index));
serviceList.remove(printer.getPrintService()); // existing match
} else {
if(exhaustive) {
Expand Down

0 comments on commit 54f1871

Please sign in to comment.