Skip to content

Commit

Permalink
Cherry-pick default printer fixes from 2.1: 67b6448, 914f6c0
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf committed Mar 25, 2022
1 parent e12f577 commit f2258be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/qz/printer/PrintServiceMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static NativePrinter getDefaultPrinter() {
printers.putAll(defaultService);
}

return printers.get(defaultService.getName());
return printers.get(defaultService);
}

public static String findPrinterName(String query) throws JSONException {
Expand All @@ -81,7 +81,7 @@ public static NativePrinter matchPrinter(String printerSearch, boolean silent) {
if (!silent) { log.debug("Searching for PrintService matching {}", printerSearch); }

NativePrinter defaultPrinter = getDefaultPrinter();
if (printerSearch.equals(defaultPrinter.getName())) {
if (defaultPrinter != null && printerSearch.equals(defaultPrinter.getName())) {
if (!silent) { log.debug("Matched default printer, skipping further search"); }
return defaultPrinter;
}
Expand Down
9 changes: 9 additions & 0 deletions src/qz/printer/info/NativePrinterMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,13 @@ public boolean contains(PrintService service) {
}
return false;
}

public NativePrinter get(PrintService service) {
for (NativePrinter printer : values()) {
if (printer.getPrintService().equals(service)) {
return printer;
}
}
return null;
}
}

0 comments on commit f2258be

Please sign in to comment.