From 4156b13c322af8a8b01b886600b74bfe9069b1ac Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Wed, 27 Jan 2021 22:52:54 +0000 Subject: [PATCH] Desktop: Fixed plugin panel issue that could crash app in rare case Ref: https://discourse.joplinapp.org/t/rearranging-the-pannels-crushed-the-app-and-generated-fatal-error/14373 --- packages/app-desktop/gui/MainScreen/MainScreen.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/app-desktop/gui/MainScreen/MainScreen.tsx b/packages/app-desktop/gui/MainScreen/MainScreen.tsx index bf21ec920..246337f19 100644 --- a/packages/app-desktop/gui/MainScreen/MainScreen.tsx +++ b/packages/app-desktop/gui/MainScreen/MainScreen.tsx @@ -572,6 +572,15 @@ class MainScreenComponent extends React.Component { } resizableLayout_renderItem(key: string, event: any) { + // Key should never be undefined but somehow it can happen, also not + // clear how. For now in this case render nothing so that the app + // doesn't crash. + // https://discourse.joplinapp.org/t/rearranging-the-pannels-crushed-the-app-and-generated-fatal-error/14373?u=laurent + if (!key) { + console.error('resizableLayout_renderItem: Trying to render an item using an empty key. Full layout is:', this.props.mainLayout); + return null; + } + const eventEmitter = event.eventEmitter; // const viewsToRemove:string[] = [];