`scanLabeledControl` logic issue
Closed this issue · 2 comments
InAnYan commented
JabRef version
5.13 (latest release)
Operating system
Windows
Details on version and operating system
No response
Checked with the latest development build (copy version output from About dialog)
- I made a backup of my libraries before testing the latest development version.
- I have tested the latest development version and the problem persists
Steps to reproduce the behaviour
- I've made a custom properties tab. It contains
Label
's,CheckBox
'es,TextField
's,TextArea
's, and...Text
's. - I've got a runtime error (details are in the appendix)
Appendix
...
Log File
java.lang.IllegalStateException: Cannot load org.jabref.gui.preferences.preferencesdialog
at afterburner.fx/com.airhacks.afterburner.views.ViewLoader.load(ViewLoader.java:174)
at org.jabref@100.0.0/org.jabref.gui.preferences.PreferencesDialogView.<init>(PreferencesDialogView.java:53)
at org.jabref@100.0.0/org.jabref.gui.preferences.ShowPreferencesAction.execute(ShowPreferencesAction.java:26)
at org.jabref@100.0.0/org.jabref.gui.actions.JabRefAction.lambda$new$3(JabRefAction.java:40)
at org.controlsfx.controls@11.2.1/org.controlsfx.control.action.Action.handle(Action.java:423)
at org.controlsfx.controls@11.2.1/org.controlsfx.control.action.Action.handle(Action.java:64)
at javafx.base@22.0.1/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at javafx.base@22.0.1/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:232)
at javafx.base@22.0.1/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:189)
at javafx.base@22.0.1/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base@22.0.1/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base@22.0.1/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base@22.0.1/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.base@22.0.1/javafx.event.Event.fireEvent(Event.java:198)
at javafx.controls@22.0.1/javafx.scene.control.MenuItem.fire(MenuItem.java:459)
at javafx.controls@22.0.1/com.sun.javafx.scene.control.ContextMenuContent$MenuItemContainer.doSelect(ContextMenuContent.java:1415)
at javafx.controls@22.0.1/com.sun.javafx.scene.control.ContextMenuContent$MenuItemContainer.lambda$createChildren$12(ContextMenuContent.java:1368)
at javafx.base@22.0.1/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247)
at javafx.base@22.0.1/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at javafx.base@22.0.1/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:232)
at javafx.base@22.0.1/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:189)
at javafx.base@22.0.1/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at javafx.base@22.0.1/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base@22.0.1/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base@22.0.1/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base@22.0.1/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base@22.0.1/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base@22.0.1/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base@22.0.1/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base@22.0.1/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base@22.0.1/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base@22.0.1/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.base@22.0.1/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics@22.0.1/javafx.scene.Scene$MouseHandler.process(Scene.java:3985)
at javafx.graphics@22.0.1/javafx.scene.Scene.processMouseEvent(Scene.java:1891)
at javafx.graphics@22.0.1/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2709)
at javafx.graphics@22.0.1/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:411)
at javafx.graphics@22.0.1/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:301)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at javafx.graphics@22.0.1/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:450)
at javafx.graphics@22.0.1/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:430)
at javafx.graphics@22.0.1/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:449)
at javafx.graphics@22.0.1/com.sun.glass.ui.View.handleMouseEvent(View.java:551)
at javafx.graphics@22.0.1/com.sun.glass.ui.View.notifyMouse(View.java:937)
at javafx.graphics@22.0.1/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at javafx.graphics@22.0.1/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$10(GtkApplication.java:264)
at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: javafx.fxml.LoadException:
/home/ruslan/Projects/JabRef/build/resources/main/org/jabref/gui/preferences/PreferencesDialog.fxml
at javafx.fxml@22.0.1/javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2727)
at javafx.fxml@22.0.1/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2697)
at javafx.fxml@22.0.1/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2568)
at javafx.fxml@22.0.1/javafx.fxml.FXMLLoader.load(FXMLLoader.java:2536)
at afterburner.fx/com.airhacks.afterburner.views.ViewLoader.load(ViewLoader.java:172)
... 46 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:109)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:72)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at javafx.base@22.0.1/com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:270)
at javafx.fxml@22.0.1/com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:84)
at javafx.fxml@22.0.1/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2693)
... 49 more
Caused by: java.lang.ClassCastException: class javafx.scene.text.Text cannot be cast to class javafx.scene.Parent (javafx.scene.text.Text and javafx.scene.Parent are in module javafx.graphics@22.0.1 of loader 'app')
at org.jabref@100.0.0/org.jabref.gui.preferences.PreferencesSearchHandler.scanLabeledControls(PreferencesSearchHandler.java:94)
at org.jabref@100.0.0/org.jabref.gui.preferences.PreferencesSearchHandler.scanLabeledControls(PreferencesSearchHandler.java:94)
at org.jabref@100.0.0/org.jabref.gui.preferences.PreferencesSearchHandler.getPrefsTabLabelMap(PreferencesSearchHandler.java:81)
at org.jabref@100.0.0/org.jabref.gui.preferences.PreferencesSearchHandler.<init>(PreferencesSearchHandler.java:27)
at org.jabref@100.0.0/org.jabref.gui.preferences.PreferencesDialogView.initialize(PreferencesDialogView.java:85)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
... 56 more
InAnYan commented
The problem lies here:
private static void scanLabeledControls(Parent parent, ArrayListMultimap<PreferencesTab, Labeled> prefsTabLabelMap, PreferencesTab preferencesTab) {
for (Node child : parent.getChildrenUnmodifiable()) {
if (!(child instanceof Labeled)) {
scanLabeledControls((Parent) child, prefsTabLabelMap, preferencesTab);
} else {
Labeled labeled = (Labeled) child;
if (!labeled.getText().isEmpty()) {
prefsTabLabelMap.put(preferencesTab, labeled);
}
}
}
}
In this code there are two branches for a child
:
- If a
child
isLabeled
: add it toprefsTabLabelMap
. - If it's not, then TREAT IT AS A PARENT, and look into other children.
So, if you have only Labeled
and Parent
controls in your preferences tab, then it's all good.
But, in my case I've added Text
control. (Don't ask me why, maybe I really shouldn't do it).
What change I propose: make 3 branches:
- If the
child
isLabeled
: add it toprefsTabLabelMap
. - If it's a
Parent
: look into it's children. - Otherwise, ignore
InAnYan commented
I've made the changes and now the error disappeared.
I'm not really sure how to test this properly, but I'll make the PR