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

Java Exception when trying to open the preferences with missing custom theme #7177

Closed
AtrusRiven opened this issue Dec 11, 2020 · 4 comments · Fixed by #7292
Closed

Java Exception when trying to open the preferences with missing custom theme #7177

AtrusRiven opened this issue Dec 11, 2020 · 4 comments · Fixed by #7292
Labels
good first issue An issue intended for project-newcomers. Varies in difficulty. type: enhancement

Comments

@AtrusRiven
Copy link
Contributor

JabRef 5.2--2020-12-09--d1fb9e2

When trying to open the preferences dialogue a java exception occurs:
Cannot load org.jabref.gui.preferences.preferencesdialog

@AtrusRiven
Copy link
Contributor Author

Could solve the problem: Obviously, a broken path of the custom theme CSS (due to a change of the name of the folder containing the custom theme CSS) caused the exception. After reinstalling the release version, having been able to change all paths in this version (this version didn't have the custom theme feature) and reinstalling the current master branch version, all works again. Maybe a better handling of broken paths could prevent such exceptions?

@Siedlerchr Siedlerchr changed the title Java Exception when trying to open the preferences dialogue Java Exception when trying to open the preferences with missing custom theme Dec 11, 2020
@Siedlerchr Siedlerchr added good first issue An issue intended for project-newcomers. Varies in difficulty. type: enhancement labels Dec 11, 2020
@calixtus
Copy link
Member

We'll will take a look at this. Unfortunately, I believe this problem may sit deeper in the javafx library, since the css' are handled there... We will see.

@docrjp
Copy link
Contributor

docrjp commented Jan 4, 2021

I'm having a look at this as a first contribution attempt.

I was able to reproduce the issue as reported:

  1. Made up a nonsense path in the custom theme text box of the preferences dialog.
  2. Restarted app successfully.
  3. Clicked again on menu Options -> Preferences
  4. Dialog box pops up with uncaught exception in JavaFX application thread including stack trace.

Observation: the bad CSS path does not affect the application overall. Only previews are impacted (and the preference dialog has a preview tab).

After some code inspection and debugging, I can see the reason for this. JabRefPreferences has logic to check if the custom css file exists, and store it as a URL if it does, otherwise no URL is stored in the Optional value. This is what the application uses in general. However, the preview viewer bypasses this logic, and directly parses the path, which is exposed by a getter.

That getter is also used for saving the settings, so I think it should stay.

I successfully tried out a tentative fix: adding a second getter that exposes the URL as processed by JabRefPreferences. Only if this URL is set, will the preview viewer use it. However, I would like to take a bit more time to consider if there is a better solution, and get my head around the contribution guidelines, before I submit a PR.

One final thought. I think that the preferences tab should show a validation hint when the file is missing. It wouldn't have prevented this case, because as I understand it, the path was correct at the time of configuration and changed only later. Still, I think it would help the user when their CSS file is moved or mistyped. I am happy to create a separate issue for this and give it a go; I don't think it should block the fix of the uncaught exception.

@calixtus
Copy link
Member

calixtus commented Jan 4, 2021

Hi @docrjp , thank you very much for diving into the code and creating a fix. Can you please create a pull request with your changes, so it's somewhat easier to discuss them?

docrjp added a commit to docrjp/jabref that referenced this issue Jan 4, 2021
docrjp added a commit to docrjp/jabref that referenced this issue Jan 5, 2021
docrjp added a commit to docrjp/jabref that referenced this issue Jan 5, 2021
docrjp added a commit to docrjp/jabref that referenced this issue Jan 7, 2021
docrjp added a commit to docrjp/jabref that referenced this issue Jan 8, 2021
docrjp added a commit to docrjp/jabref that referenced this issue Jan 8, 2021
docrjp added a commit to docrjp/jabref that referenced this issue Jan 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue An issue intended for project-newcomers. Varies in difficulty. type: enhancement
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants