Fix BEAUti crash for single valued distr inputs (ScalarDistributionInputEditor) - #126
Merged
walterxie merged 1 commit intoJul 27, 2026
Merged
Conversation
The editor assumed its input is always a list of distributions, so it failed when created for a single ScalarDistribution valued input, such as the distr input of a Prior. Since the static template caches were only half filled when that failed, every editor created afterwards failed as well with an unrelated IndexOutOfBoundsException, which is what BEAUti reported to the user (see BEAST2-Dev/bModelTest#10). - resolve the distribution being edited from either the list entry or the value of the input itself - publish the template caches only once they are complete - fall back to the partition context of the object owning the input when the nested distribution has no ID of its own - register a replacement distribution as output of the object owning the input rather than of the distribution it replaces - suppress the combo box, rather than throw, when no templates are known
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Opening the Priors panel in BEAUti with a package that wraps a distribution in another
Distribution— e.g. bModelTest'sBMTPrior, which has a singleScalarDistributionvalueddistrinput — pops up "Could not add entry for distr" (BEAST2-Dev/bModelTest#10):init()assumed the input is always a list of distributions with a valid item number:For a single valued
distrinput this is reached with the distribution itself as value anditemNr == -1, so it throws.scalarTemplateshad already been assigned at that point whiletemplateDomainswas still empty, so every editor created afterwards skipped thescalarTemplates == nullguard and died ontemplateDomains.get(k++)— the reported symptom. The combo box change handler already had a branch for non-list inputs, so single valued inputs were clearly meant to be supported.Fix
getDistribution)contextFor)Test
ScalarDistributionInputEditorTestbuilds aBeautiDocfrom the Standard template and asksInputEditorFactoryfor an editor for thedistrinput of aDistributionwrapper twice, which is what BEAUti does when rendering a panel. Without the fix it reproduces both the initialClassCastExceptionand theIndexOutOfBoundsExceptionfrom the issue; with the fix it passes.Full
beast-fxsuite: 23 run, 0 failures, 0 errors (11 skipped).