Skip to content

Commit 44080a7

Browse files
Fix undefined access on not-existing segmentation layer (#5583)
* fix undefined access on not-existing segmentation layer * update changelog * Update CHANGELOG.unreleased.md Co-authored-by: Daniel <[email protected]> Co-authored-by: Daniel <[email protected]>
1 parent 0e42443 commit 44080a7

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

CHANGELOG.unreleased.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
2323
### Fixed
2424
- Fixed that a disabled "Center new Nodes" option didn't work correctly in merger mode. [#5538](https://github.com/scalableminds/webknossos/pull/5538)
2525
- Fixed a bug where dataset uploads of zips with just one file inside failed. [#5534](https://github.com/scalableminds/webknossos/pull/5534)
26+
- Fixed a benign error message when a dataset without a segmentation layer was opened in view mode or with a skeleton-only annotation. [#5583](https://github.com/scalableminds/webknossos/pull/5583)
2627
- Fixed crashing tree tab which could happen when dragging a node and then switching directly to another tab (e.g., comments) and then back again. [#5573](https://github.com/scalableminds/webknossos/pull/5573)
2728
- Fixed that the UI allowed mutating trees in the tree tab (dragging/creating/deleting trees and groups) in read-only tracings. [#5573](https://github.com/scalableminds/webknossos/pull/5573)
2829
- Fixed "Create a new tree group for this file" setting in front-end import when a group id of 0 was used in the NML. [#5573](https://github.com/scalableminds/webknossos/pull/5573)

frontend/javascripts/oxalis/view/layouting/default_layout_configs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// @flow
99
import _ from "lodash";
1010

11+
import type { ExtractReturn } from "libs/type_helpers";
1112
import { getIsInIframe } from "libs/utils";
1213
import { navbarHeight } from "navbar";
1314
import Constants, {
@@ -298,7 +299,6 @@ export const resetDefaultLayouts = () => {
298299
getDefaultLayouts.cache.clear();
299300
};
300301

301-
type ExtractReturn<Fn> = $Call<<T>(() => T) => T, Fn>;
302302
type Layout = $Keys<ExtractReturn<typeof _getDefaultLayouts>>;
303303

304304
export const getCurrentDefaultLayoutConfig = () => {

frontend/javascripts/oxalis/view/node_context_menu.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,7 @@ function NoNodeContextMenuOptions({
200200
}: NoNodeContextMenuProps) {
201201
useEffect(() => {
202202
(async () => {
203-
if (segmentationLayer) {
204-
await maybeFetchMeshFiles(segmentationLayer, dataset, false);
205-
}
203+
await maybeFetchMeshFiles(segmentationLayer, dataset, false);
206204
})();
207205
}, []);
208206

frontend/javascripts/oxalis/view/right-menu/meshes_view.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const stlIsosurfaceConstants = {
5959

6060
// This file defines the component MeshesView.
6161

62-
const mapStateToProps = (state: OxalisState) => ({
62+
const mapStateToProps = (state: OxalisState): * => ({
6363
meshes: state.tracing != null ? state.tracing.meshes : [],
6464
isImporting: state.uiInformation.isImportingMesh,
6565
isosurfaces: state.isosurfaces,
@@ -75,7 +75,7 @@ const mapStateToProps = (state: OxalisState) => ({
7575
currentMeshFile: state.currentMeshFile,
7676
});
7777

78-
const mapDispatchToProps = (dispatch: Dispatch<*>) => ({
78+
const mapDispatchToProps = (dispatch: Dispatch<*>): * => ({
7979
updateRemoteMeshMetadata(id: string, meshMetaData: $Shape<RemoteMeshMetaData>) {
8080
dispatch(updateRemoteMeshMetaDataAction(id, meshMetaData));
8181
},
@@ -121,8 +121,9 @@ const mapDispatchToProps = (dispatch: Dispatch<*>) => ({
121121
});
122122

123123
type DispatchProps = ExtractReturn<typeof mapDispatchToProps>;
124+
type StateProps = ExtractReturn<typeof mapStateToProps>;
124125

125-
type Props = {| ...DispatchProps |};
126+
type Props = {| ...DispatchProps, ...StateProps |};
126127

127128
type State = { hoveredListItem: ?number };
128129

@@ -257,6 +258,9 @@ class MeshesView extends React.Component<Props, State> {
257258
Toast.info("No cell found at centered position");
258259
return;
259260
}
261+
if (!this.props.currentMeshFile || !this.props.segmentationLayer) {
262+
return;
263+
}
260264
await loadMeshFromFile(
261265
id,
262266
pos,
@@ -295,12 +299,12 @@ class MeshesView extends React.Component<Props, State> {
295299
);
296300

297301
const getLoadPrecomputedMeshButton = () => {
298-
const hasCurrenMeshFile = this.props.currentMeshFile;
302+
const hasCurrentMeshFile = this.props.currentMeshFile;
299303
return (
300304
<Tooltip
301305
key="tooltip"
302306
title={
303-
hasCurrenMeshFile
307+
this.props.currentMeshFile != null
304308
? `Load mesh for centered cell from file ${this.props.currentMeshFile}`
305309
: "There is no mesh file."
306310
}
@@ -312,7 +316,7 @@ class MeshesView extends React.Component<Props, State> {
312316
overlay={getMeshFilesDropdown()}
313317
buttonsRender={([leftButton, rightButton]) => [
314318
React.cloneElement(leftButton, {
315-
disabled: !hasCurrenMeshFile,
319+
disabled: !hasCurrentMeshFile,
316320
style: { borderRightStyle: "dashed" },
317321
}),
318322
React.cloneElement(rightButton, { style: { borderLeftStyle: "dashed" } }),

frontend/javascripts/oxalis/view/right-menu/meshes_view_helper.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@ import processTaskWithPool from "libs/task_pool";
2424
const PARALLEL_MESH_LOADING_COUNT = 6;
2525

2626
export async function maybeFetchMeshFiles(
27-
segmentationLayer: APIDataLayer,
27+
segmentationLayer: ?APIDataLayer,
2828
dataset: APIDataset,
2929
mustRequest: boolean,
3030
): Promise<void> {
31+
if (!segmentationLayer) {
32+
return;
33+
}
3134
const files = Store.getState().availableMeshFiles;
3235

3336
// only send new get request, if it hasn't happened before (files in store are null)

0 commit comments

Comments
 (0)