Skip to content

Commit

Permalink
Fix corruption of skeleton when using CTRL+Rightclick in empty tree (#…
Browse files Browse the repository at this point in the history
…5385)

* avoid corruption of skeleton in weird case; also ensure that first node of a tree is always selected after creation

* update changelog
  • Loading branch information
philippotto authored Apr 12, 2021
1 parent 584cfb9 commit 004b64f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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)
- Fixed a bug in Safari which could cause an error message (which is safe to ignore). [#5373](https://github.com/scalableminds/webknossos/pull/5373)
- Fixed artifacts in screenshots near the dataset border. [#5324](https://github.com/scalableminds/webknossos/pull/5324)
- Fixed a bug where the page would scroll up unexpectedly when showing various confirm modals. [#5371](https://github.com/scalableminds/webknossos/pull/5371)
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

0 comments on commit 004b64f

Please sign in to comment.