Skip to content

Commit 0f868b8

Browse files
Print entry preview NullPointerException handling (#13776)
* feat: print entry preview NullPointerException handling * fix: typo * feat: added a CHANGELOG.md entry for the latest fix * Update CHANGELOG.md * fix: added full link to latest CHANGELOG.md --------- Co-authored-by: Subhramit Basu <[email protected]>
1 parent f2b4331 commit 0f868b8

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
1111

1212
### Added
1313

14+
- We fixed an issue where "Print preview" would throw a `NullPointerException` if no printers were available. [#13708](https://github.com/JabRef/jabref/issues/13708)
1415
- We added the option to enable the language server in the preferences. [#13697](https://github.com/JabRef/jabref/pull/13697)
1516
- We introduced an option in Preferences under (under Linked files -> Linked file name conventions) to automatically rename linked files when an entry data changes. [#11316](https://github.com/JabRef/jabref/issues/11316)
1617
- We added tooltips (on hover) for 'Library-specific file directory', 'User-specific file directory' and 'LaTeX file directory' fields of the library properties window. [#12269](https://github.com/JabRef/jabref/issues/12269)

jabgui/src/main/java/org/jabref/gui/preview/PreviewViewer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ private void highlightLayoutText() {
248248

249249
public void print() {
250250
PrinterJob job = PrinterJob.createPrinterJob();
251+
if (job == null) {
252+
LOGGER.warn("PrinterJob.createPrinterJob() returned null; printing not available");
253+
dialogService.showErrorDialogAndWait("Could not find an available printer");
254+
return;
255+
}
251256
if ((entry == null) || !dialogService.showPrintDialog(job)) {
252257
return;
253258
}

0 commit comments

Comments
 (0)