fix(seg-viewport): add guard for missing reference display set handler to prevent viewport crash (#5618)

This commit is contained in:
Ghadeer Albattarni 2025-12-09 17:20:11 -05:00 committed by GitHub
parent 442ee68599
commit 8dde2237a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -60,15 +60,26 @@ function OHIFCornerstoneSEGViewport(props: withAppTypes) {
// In such cases, we attempt to handle this scenario gracefully by // In such cases, we attempt to handle this scenario gracefully by
// invoking a custom handler. Ideally, if a user tries to launch a series that isn't viewable, // invoking a custom handler. Ideally, if a user tries to launch a series that isn't viewable,
// (eg.: we can prompt them with an explanation and provide a link to the full study). // (eg.: we can prompt them with an explanation and provide a link to the full study).
// Additional guard: If no customization handler is registered for missing
// referenced display sets, skip SEG rendering to avoid a viewport crash.
if (!referencedDisplaySetInstanceUID) { if (!referencedDisplaySetInstanceUID) {
const missingReferenceDisplaySetHandler = customizationService.getCustomization( const missingReferenceDisplaySetHandler = customizationService.getCustomization(
'missingReferenceDisplaySetHandler' 'missingReferenceDisplaySetHandler'
); );
const { handled } = missingReferenceDisplaySetHandler(); if (typeof missingReferenceDisplaySetHandler === 'function') {
if (handled) { const { handled } = missingReferenceDisplaySetHandler();
if (handled) {
return;
}
} else {
console.log(
"No customization 'missingReferenceDisplaySetHandler' registered. Skipping SEG rendering."
);
return; return;
} }
} }
const referencedDisplaySet = displaySetService.getDisplaySetByUID( const referencedDisplaySet = displaySetService.getDisplaySetByUID(
referencedDisplaySetInstanceUID referencedDisplaySetInstanceUID
); );