mastodon-sc / mastodon

Mastodon – a large-scale tracking and track-editing framework for large, multi-view images.
BSD 2-Clause "Simplified" License
66 stars 20 forks source link

FixImagePath NPE on NewMastodonProject from ImageOpenedInImageJ #228

Closed xulman closed 8 months ago

xulman commented 1 year ago

...likely because there exists no project's xml yet

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at org.mastodon.mamut.tomancak.DatasetPathDialog.<init>(DatasetPathDialog.java:107)
    at org.mastodon.mamut.tomancak.DatasetPathDialog.<init>(DatasetPathDialog.java:98)
    at org.mastodon.mamut.tomancak.TomancakPlugins.tweakDatasetPath(TomancakPlugins.java:397)
    at org.scijava.ui.behaviour.util.RunnableAction.actionPerformed(RunnableAction.java:47)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)

The c'tor at L107 should be more smarter and test if it has gotten non-null project reference.

And if it got null ref, show a new dialog "sorry, no project yet, please save it first" (or alike) and avoid throwing NPE because indeed the issue is gone after the project is saved (tested myself).

xulman commented 1 year ago

(I apparently cannot assign the issue to myself, nor can I give it a label... but I'm okay with that, just FYI)

tinevez commented 1 year ago

How do you reproduce this bug? I have no error message when creating a project from an ImagePlus.

xulman commented 1 year ago
  1. fresh Fiji
  2. install Mastodon update site
  3. open any TIFF into Fiji
  4. open Mastodon
  5. choose "new Mastodon project", then "use an image opened in ImageJ"
  6. click "create", Mastodon opens normally
  7. click File -> Fix Image Path
  8. NPE comes out...
tinevez commented 1 year ago

Ahhhhhh I missed the last part. Indeed: image

Do you want to work on it?

xulman commented 1 year ago

I can....

It breaks here, I would solve it by adding a guarding-test before that line, e.g.,

if (project == null || project.getProjectRoot() == null) {
     code to create a different dialog content -- a content that informs
     that it cannot be fixing a path in a project when there's no project created yet
}