Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only search for classes if a stylesheet is provided #163

Merged
merged 1 commit into from
Jan 5, 2019

Conversation

martinklepsch
Copy link
Contributor

fixes #159

While in #159 the root cause was described as a missing class I think it's actually a nil stylesheet that will cause the NPE when (map stylesheet class) is called.

All of the following invocations should now work fine:

(pdf
 [{:stylesheet {:custom {:size 40}}}
  [:phrase.custom "Styled"]]
 "test.pdf")

;; worked
(pdf
 [{:stylesheet {:wrong {:size 10}}}
  [:phrase.custom "Styled"]]
 "test.pdf")

;; failed, works now
(pdf
 [{}
  [:phrase.custom "Styled"]]
 "test.pdf")

;; failed, works now
(pdf
 [nil
  [:phrase.custom "Styled"]]
 "test.pdf")

;; failed, works now
(pdf
 [{:stylesheet nil}
  [:phrase.custom "Styled"]]
 "test.pdf")

About the code:

  • The fallback could also be handled in get-class-attributes (?)
  • I'm not sure what the cond-> in line 39 is good for since merging nil is the same as not merging anything.

@yogthos yogthos merged commit 3bf8ab5 into clj-pdf:master Jan 5, 2019
@yogthos
Copy link
Collaborator

yogthos commented Jan 5, 2019

Thanks, I just pushed out 2.3.1 with the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If a class has no corresponding stylesheet entry, it throws an NPE without any information
2 participants