powsybl / powsybl-dev-tools

2 stars 1 forks source link

Exception thrown when trying to open a new file if the last opened file/folder has been deleted #101

Open rolnico opened 6 months ago

rolnico commented 6 months ago

Describe the current behavior

When I try to open a new file (by clicking on the "..." button on the top right), I get an exception:

Describe the expected behavior

In both cases, no exception should be thrown and the window should open in any case (by default, in either the user's home directory or the project's directory)

Describe the steps

  1. Open the diagram viewer
  2. Open a file in some specific folder (that you can delete later) --> this works
  3. Delete the file
  4. Try to open another file --> Exception thrown but the window opens
  5. Delete the folder
  6. Try to open another file --> Exception thrown and the window does not open

Environment

No response

Relevant Log Output

2024-03-13_15:08:58.854 [JavaFX Application Thread] ERROR c.p.d.viewer.MainViewController - com.powsybl.commons.PowsyblException: File /home/rolnic/projects/workspace/powsybl-network-store/network-store-iidm-impl/src/test/resources/test.xiidm does not exist or is not a regular file
com.powsybl.commons.PowsyblException: File /home/rolnic/projects/workspace/powsybl-network-store/network-store-iidm-impl/src/test/resources/test.xiidm does not exist or is not a regular file
    at com.powsybl.commons.datasource.DataSource.fromPath(DataSource.java:29)
    at com.powsybl.iidm.network.Network.read(Network.java:124)
    at com.powsybl.iidm.network.Network.read(Network.java:134)
    at com.powsybl.iidm.network.Network.read(Network.java:148)
    at com.powsybl.iidm.network.Network.read(Network.java:162)
    at com.powsybl.diagram.viewer.MainViewController$2$1.call(MainViewController.java:185)
    at com.powsybl.diagram.viewer.MainViewController$2$1.call(MainViewController.java:180)
    at javafx.graphics@19.0.2.1/javafx.concurrent.Task$TaskCallable.call(Task.java:1426)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at javafx.graphics@19.0.2.1/javafx.concurrent.Service.lambda$executeTask$6(Service.java:726)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at javafx.graphics@19.0.2.1/javafx.concurrent.Service.lambda$executeTask$7(Service.java:725)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)

If the folder has been deleted, you get the previous log followed by:

Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at javafx.fxml@19.0.2.1/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1857)
    at javafx.fxml@19.0.2.1/javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1724)
    at javafx.base@19.0.2.1/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    at javafx.base@19.0.2.1/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
    at javafx.base@19.0.2.1/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at javafx.base@19.0.2.1/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at javafx.base@19.0.2.1/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at javafx.base@19.0.2.1/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base@19.0.2.1/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base@19.0.2.1/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base@19.0.2.1/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base@19.0.2.1/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base@19.0.2.1/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at javafx.base@19.0.2.1/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.base@19.0.2.1/javafx.event.Event.fireEvent(Event.java:198)
    at javafx.graphics@19.0.2.1/javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3599)
    at javafx.graphics@19.0.2.1/javafx.scene.Scene$MouseHandler.process(Scene.java:3903)
    at javafx.graphics@19.0.2.1/javafx.scene.Scene.processMouseEvent(Scene.java:1887)
    at javafx.graphics@19.0.2.1/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2620)
    at javafx.graphics@19.0.2.1/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:411)
    at javafx.graphics@19.0.2.1/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:301)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at javafx.graphics@19.0.2.1/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:450)
    at javafx.graphics@19.0.2.1/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:424)
    at javafx.graphics@19.0.2.1/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:449)
    at javafx.graphics@19.0.2.1/com.sun.glass.ui.View.handleMouseEvent(View.java:551)
    at javafx.graphics@19.0.2.1/com.sun.glass.ui.View.notifyMouse(View.java:937)
    at javafx.graphics@19.0.2.1/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at javafx.graphics@19.0.2.1/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:316)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:77)
    at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at javafx.base@19.0.2.1/com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:275)
    at javafx.fxml@19.0.2.1/com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:84)
    at javafx.fxml@19.0.2.1/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1852)
    ... 29 more
Caused by: java.lang.IllegalArgumentException: Folder parameter must be a valid folder
    at javafx.graphics@19.0.2.1/com.sun.glass.ui.CommonDialogs.convertFolder(CommonDialogs.java:239)
    at javafx.graphics@19.0.2.1/com.sun.glass.ui.CommonDialogs.showFileChooser(CommonDialogs.java:191)
    at javafx.graphics@19.0.2.1/com.sun.javafx.tk.quantum.QuantumToolkit.showFileChooser(QuantumToolkit.java:1702)
    at javafx.graphics@19.0.2.1/javafx.stage.FileChooser.showDialog(FileChooser.java:419)
    at javafx.graphics@19.0.2.1/javafx.stage.FileChooser.showOpenDialog(FileChooser.java:354)
    at com.powsybl.diagram.viewer.MainViewController.onClickLoadFile(MainViewController.java:171)
    ... 40 more

Extra Information

No response

tadam50 commented 5 months ago

Fixed by #109