constellation icon indicating copy to clipboard operation
constellation copied to clipboard

NullPointerException when closing a new graph and choosing to save at the prompt

Open Auriga2 opened this issue 2 years ago • 5 comments

Prerequisites

  • [x] Put an X between the brackets on this line if you have done all of the following:

    • Running the latest version of Constellation

    • Attached the Support Package via Help > Support Package

    • Checked the FAQs: https://github.com/constellation-app/constellation/wiki/FAQ

    • Checked that your issue isn’t already filed: https://github.com/constellation-app/constellation/issues

    • Checked that there is not already a module that provides the described functionality: https://github.com/constellation-app/constellation/wiki/Catalogue-of-Repositories

Description

  1. Below exception is thrown when you close a new graph and choose to save it at the prompt.
java.lang.NullPointerException
	at au.gov.asd.tac.constellation.graph.interaction.plugins.io.screenshot.RecentGraphScreenshotUtilities.takeScreenshot(RecentGraphScreenshotUtilities.java:95)
	at au.gov.asd.tac.constellation.graph.interaction.gui.VisualGraphTopComponent$WriteGraphFile.execute(VisualGraphTopComponent.java:1237)
	at au.gov.asd.tac.constellation.plugins.templates.SimplePlugin.run(SimplePlugin.java:68)
[catch] at au.gov.asd.tac.constellation.graph.node.plugins.DefaultPluginEnvironment.lambda$executePluginLater$0(DefaultPluginEnvironment.java:131)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

  1. Also if you open an already saved graph and modify it and then click the close button, it prompts to save. But if you click save there, it doesn't close the graph after saving, it just saves and keeps it open.

Steps to Reproduce

To reproduce 1

  1. Draw a new graph and click on the close button

  2. At the prompt click Save and in the next pop up window enter a proper name and click Save

Expected behaviour: No exception is thrown and graph is closed after saving

Actual behaviour: An exception is thrown and graph is not closed after saving

Reproduces how often: 100%

Additional Information

Auriga2 avatar Mar 08 '22 01:03 Auriga2

This issue is stale because it has been open for 6 months with no activity. Consider reviewing and taking an action on this issue.

github-actions[bot] avatar Sep 05 '22 00:09 github-actions[bot]

@antares1470 Through testing I have found that the null pointer no longer occurs in rc v.2.8.0 or on the main branch but it did occur on v2.6.0, indicating that something has been done to fix it. The second dot point described in this ticket still occurs, where closing the graph and choosing save doesn't actually close the graph after it has been saved.

Delphinus8821 avatar Sep 06 '22 00:09 Delphinus8821

@antares1470 Through testing I have found that the null pointer no longer occurs in rc v.2.8.0 or on the main branch but it did occur on v2.6.0, indicating that something has been done to fix it. The second dot point described in this ticket still occurs, where closing the graph and choosing save doesn't actually close the graph after it has been saved.

@Delphinus8821 I think the null pointer still exists. If you look at RecentGraphScreenshotUtilities back at what it would have been in March (when this ticket was created), the lines in question were the following in the takeScreenshot() function:

94:   final GraphNode graphNode = GraphNode.getGraphNode(GraphManager.getDefault().getActiveGraph());
95:   final VisualManager visualManager = graphNode.getVisualManager();

Based on the stack trace, I would guess the null pointer is for graphNode. While there have been changes made to that class since then, those 2 lines remain untouched within that function (though they are now lines 142 and 143 of the class) so if I'm right, the null pointer probably still exists (note that GraphNode and GraphManager both remain untouched since March)

antares1470 avatar Sep 06 '22 00:09 antares1470

@antares1470 In testing in v2.6.0 I am able to reproduce the null pointer and I believe it is caused because after a save the graph is closed and then the null pointer is thrown, so its trying to take a screenshot of a graph that is already closed. On the main branch and rc v2.8.0 the null pointer is not currently being thrown because it doesn't actually close the graph after the save action anymore.

Delphinus8821 avatar Sep 06 '22 01:09 Delphinus8821

@antares1470 In testing in v2.6.0 I am able to reproduce the null pointer and I believe it is caused because after a save the graph is closed and then the null pointer is thrown, so its trying to take a screenshot of a graph that is already closed. On the main branch and rc v2.8.0 the null pointer is not currently being thrown because it doesn't actually close the graph after the save action anymore.

Right I see what you mean. In observing that, I think it only resolved because it doesn't close the graph after the save action which that in itself I think may be a bug (which is now happening after saving new graphs, not just existing ones). So fixing that one could reintroduce this null pointer depending on how it is fixed. A null check probably wouldn't hurt in any case

antares1470 avatar Sep 06 '22 01:09 antares1470

Thank you @Delphinus8821 and @antares1470 for getting to the bottom of these problems and for the detailed investigation. I have tried out both scenarios mentioned above in the latest nightly build version and didn't see any issues. Thanks for fixing it up!

GammaVel avatar Oct 21 '22 03:10 GammaVel