Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix corruption of skeleton when using CTRL+Rightclick in empty tree #5385

Merged
merged 3 commits into from
Apr 12, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Fixed a bug where some values in the project list were displayed incorrectly after pausing/unpausing the project. [#5339](https://github.com/scalableminds/webknossos/pull/5339)
- Fixed that editing a task type would always re-add the default values to the recommended configuration (if enabled). [#5341](https://github.com/scalableminds/webknossos/pull/5341)
- Fixed a bug where tasks created from existing volume annotations that did not have a specified bounding box were broken. [#5362](https://github.com/scalableminds/webknossos/pull/5361)
- Fixed a bug which could cause corrupted trees when CTRL+Rightclick was used in an empty tree. [#5385](https://github.com/scalableminds/webknossos/pull/5385)

### Removed
-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,10 @@ export function setWaypoint(
const center = state.userConfiguration.centerNewNode && !ctrlIsPressed;
// Only create a branchpoint if CTRL is pressed. Unless newNodeNewTree is activated (branchpoints make no sense then)
const branchpoint = ctrlIsPressed && !state.userConfiguration.newNodeNewTree;
// Always activate the new node unless CTRL is pressed
const activate = !ctrlIsPressed;
// Always activate the new node unless CTRL is pressed. If there is no current node,
// the new one is still activated regardless of CTRL (otherwise, using CTRL+click in an empty tree multiple times would
// not create any edges; see https://github.com/scalableminds/webknossos/issues/5303).
const activate = !ctrlIsPressed || activeNodeMaybe.isNothing;

addNode(position, rotation, createNewTree, center, branchpoint, activate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ export function createNode(
const { allowUpdate } = restrictions;
const activeNodeMaybe = getActiveNodeFromTree(skeletonTracing, tree);

if (activeNodeMaybe.isNothing && tree.nodes.size() !== 0) {
console.error("Couldn't create a node in non-empty tree, because there is no active node.");
return Maybe.Nothing();
}

if (allowUpdate) {
// Use the same radius as current active node or revert to default value
const radius = activeNodeMaybe
Expand Down