Fixing tests where n might potentially be NULL by zindy · Pull Request #1967 · qupath/qupath

Hello,

This is to solve a very unlikely edge case where the variable n (the new value of an observed property when it changes) is NULL in two tests (as far as I can tell) in the Brightness & Contrast dialog. This can happen because the dialog can be opened even if no image is available in the current viewer.

Apparently a classic autounboxing null problem (?) in Java: When n is null, this causes a NullPointerException because Java tries to invoke n.booleanValue() on a null reference.

I only noticed this because my autodock script crashed with

[JavaFX Application Thread]	ERROR	qupath.lib.gui.QuPathUncaughtExceptionHandler	Cannot invoke "java.lang.Boolean.booleanValue()" because "n" is null	java.lang.NullPointerException: Cannot invoke "java.lang.Boolean.booleanValue()" because "n" is null
	at qupath.lib.gui.commands.display.BrightnessContrastChannelPane.lambda$new$0(BrightnessContrastChannelPane.java:149)
	at com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:192)
	at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:91)
	at javafx.beans.binding.ObjectBinding.invalidate(ObjectBinding.java:192)

Cheers,
Egor