Fix a few theme-related issues#13877
Conversation
… runtime - IndexOutOfBoundsException keeps being thrown although the theme is applied correctly. By catching the exception, we avoid spamming the exception to user.
|
Please don't squash before merging, as each commit addresses a separate issue. |
|
When I go to prefs -> Change from light to dark theme |
|
I also experience the IndexOutOfBoundsException when I switch the theme first from light to dark then dark to light: |
| installCssImmediately(scene); | ||
| } catch (IndexOutOfBoundsException e) { | ||
| // IndexOutOfBoundsException keeps being thrown although the theme is applied correctly. | ||
| // By catching the exception, we avoid spamming the exception to user. |
There was a problem hiding this comment.
I don't think you can actually catch the IndexOfOutBoundsException... For some magic that I cannot fully understood, even with that, I can get an error similar to this:
java.lang.IndexOutOfBoundsException: toIndex = 3
at java.base/java.util.AbstractList.subListRangeCheck(AbstractList.java:509)
at java.base/java.util.AbstractList.subList(AbstractList.java:499)
at javafx.base@24.0.2/javafx.collections.ModifiableObservableListBase.subList(ModifiableObservableListBase.java:234)
at javafx.base@24.0.2/com.sun.javafx.binding.ContentBinding$ListContentBinding.onChanged(ContentBinding.java:123)
at javafx.base@24.0.2/com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:327)
at javafx.base@24.0.2/com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:71)
at javafx.base@24.0.2/javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:246)
at javafx.base@24.0.2/javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
at javafx.base@24.0.2/javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
at javafx.base@24.0.2/javafx.collections.ObservableListBase.endChange(ObservableListBase.java:210)
at javafx.base@24.0.2/javafx.collections.ModifiableObservableListBase.setAll(ModifiableObservableListBase.java:102)
at org.jabref/org.jabref.gui.theme.ThemeManager.installCssImmediately(ThemeManager.java:108)
at org.jabref/org.jabref.gui.theme.ThemeManager.lambda$installCss$0(ThemeManager.java:117)
at javafx.graphics@24.0.2/com.sun.javafx.application.PlatformImpl.lambda$runLater$4(PlatformImpl.java:419)
at javafx.graphics@24.0.2/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at javafx.graphics@24.0.2/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics@24.0.2/com.sun.glass.ui.win.WinApplication.lambda$runLoop$0(WinApplication.java:168)
at java.base/java.lang.Thread.run(Thread.java:1447)I wonder if DelayedExecution utility, or first clear all the theme instead of directly setAll would perform the trick. Alternatively, the other method that I haven't tried before (when I encountered this), is to always keep the base.css and only remove the css not needed (so switch light to dark = add(dark.css); switch dark to light = remove(dark.css), instead of just performing an array of css replacement).
There was a problem hiding this comment.
I could fix this by calling clear first and then adding the new stylesheets
There was a problem hiding this comment.
The exception is less frequent now but still reproducible unfortunately.
There was a problem hiding this comment.
I don't think you can actually catch the IndexOfOutBoundsException... For some magic that I cannot fully understood, even with that, I can get an error similar to this:
I'm really confused too :), no idea how the exception is not caught. We have this setUncaughtExceptionHandler method call to catch uncaught exceptions and show them in error dialog but that should be for uncaught 🥲.
I would keep it throwing since this is not a new bug and the theme changes correctly even with the exception, and open an issue to fix it later.
| -fx-padding: 0.5em 1em 0.5em 1em; | ||
| } | ||
|
|
||
| .dialog-pane .button-bar .button { |
There was a problem hiding this comment.
There was a problem hiding this comment.
JabRef should be able to resize buttons to show full texts when font size changes but it is more important to have it work using the default font size, we can think of a better solution for that case in parallel.
The issue doesn't happen with the merge dialog only but with any dialog that has long text (more than two words) in button bar .i.e About dialog.
|
Exception no longer occurs after the latest changes. I think the only issue left was that with the icon size updating on font size change not always beeng correct |
…dated at runtime" This reverts commit 7361b5a.
Actually it still does for me. I didn't push any attempts to fix the exception, it is more involved. I reverted the commit that said it fixed this problem. I think we can merge as is, good enough for alpha release. |
|
@HoussemNasri @Yubo-Cao I merged the javafx25 now in, would be nice if could play around wtih this as well |
* upstream/main: (85 commits) Fix typo in PR template (add missing 'to') (JabRef#14050) New Crowdin updates (JabRef#14049) Switch to new macos intel runner and update arm runner as well (JabRef#14048) Automatic field editor: Add Clear content tab + viewmodel (JabRef#13824) Update dependency org.eclipse.jgit:org.eclipse.jgit.pgm to v7.4.0.202509020913-r (JabRef#14046) Rephrase JabRef-Machine's "Determine issue number" (JabRef#14044) Chore(deps): Bump com.vanniktech.maven.publish from 0.32.0 to 0.34.0 in /jablib (JabRef#14039) Chore(deps): Bump org.mockito:mockito-core in /jablib (JabRef#14038) Chore(deps): Bump jablib/src/main/resources/csl-styles (JabRef#14037) Chore(deps): Bump com.dlsc.pdfviewfx:pdfviewfx in /versions (JabRef#14040) Chore(deps): Bump lucene from 10.3.0 to 10.3.1 in /versions (JabRef#14042) Fix eadr missing (JabRef#14043) Enable update in versions of jablib (JabRef#14036) Update Gradle Wrapper from 9.3.0-jabref-1 to 9.1.0 (JabRef#14033) Implemented OpenAlex (JabRef#14020) Chore(deps): Bump peter-evans/create-or-update-comment from 4 to 5 (JabRef#14023) Chore(deps): Bump org.cyclonedx.bom from 3.0.0-alpha-1 to 3.0.0 (JabRef#14026) Chore(deps): Bump org.junit.jupiter:junit-jupiter in /versions (JabRef#14030) Chore(deps): Bump com.github.andygoossens:gradle-modernizer-plugin (JabRef#14027) Chore(deps): Bump org.mockito:mockito-core in /versions (JabRef#14028) ...
|
Your pull request needs to link an issue correctly. To ease organizational workflows, please link this pull request to the issue by including a supported keyword in the pull request's description as per syntax described in GitHub's documentation. Examples
|
Siedlerchr
left a comment
There was a problem hiding this comment.
no errors so far, should be fine
still better to have the proper text on the buttons
* Prevent brief flash of the default JavaFX (Modena) theme on startup * Avoid spamming IndexOutOfBoundsException when the theme is updated at runtime - IndexOutOfBoundsException keeps being thrown although the theme is applied correctly. By catching the exception, we avoid spamming the exception to user. * Fix button-bar buttons truncating long text with ellipsis * Update Changelog * use clear * Revert "Avoid spamming IndexOutOfBoundsException when the theme is updated at runtime" This reverts commit 7361b5a. * Update CHANGELOG.md --------- Co-authored-by: Houssem Nasri <houssem.nasri@360t.com> Co-authored-by: Siedlerchr <siedlerkiller@gmail.com>
* Prevent brief flash of the default JavaFX (Modena) theme on startup * Avoid spamming IndexOutOfBoundsException when the theme is updated at runtime - IndexOutOfBoundsException keeps being thrown although the theme is applied correctly. By catching the exception, we avoid spamming the exception to user. * Fix button-bar buttons truncating long text with ellipsis * Update Changelog * use clear * Revert "Avoid spamming IndexOutOfBoundsException when the theme is updated at runtime" This reverts commit 7361b5a. * Update CHANGELOG.md --------- Co-authored-by: Houssem Nasri <houssem.nasri@360t.com> Co-authored-by: Siedlerchr <siedlerkiller@gmail.com>


JavaFX default theme brief flash
Screen.Recording.2025-09-13.at.14.53.57.mov
Button-bar button ellipsis truncate issue
Mandatory checks
CHANGELOG.mdin a way that is understandable for the average user (if change is visible to the user)