Skip to content

Commit 51c2494

Browse files
authored
Show a crash dialog when the editor panics (#362)
* Show a crash dialog when the editor panics Closes #357 * Suppress console usage lints * Proxy cleanup and comments
1 parent 1999905 commit 51c2494

File tree

16 files changed

+212
-32
lines changed

16 files changed

+212
-32
lines changed

editor/src/document/document_message_handler.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,13 @@ impl MessageHandler<DocumentsMessage, &InputPreprocessor> for DocumentsMessageHa
202202
Ok(document) => {
203203
self.load_document(document, responses);
204204
}
205-
Err(e) => responses.push_back(FrontendMessage::DisplayError { description: e.to_string() }.into()),
205+
Err(e) => responses.push_back(
206+
FrontendMessage::DisplayError {
207+
title: "Failed to open document".to_string(),
208+
description: e.to_string(),
209+
}
210+
.into(),
211+
),
206212
}
207213
}
208214
GetOpenDocumentsList => {

editor/src/frontend/frontend_message_handler.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ pub enum FrontendMessage {
1212
SetActiveTool { tool_name: String, tool_options: Option<ToolOptions> },
1313
SetActiveDocument { document_index: usize },
1414
UpdateOpenDocumentsList { open_documents: Vec<String> },
15-
DisplayError { description: String },
15+
DisplayError { title: String, description: String },
16+
DisplayPanic { title: String, description: String },
1617
DisplayConfirmationToCloseDocument { document_index: usize },
1718
DisplayConfirmationToCloseAllDocuments,
1819
UpdateCanvas { document: String },

editor/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ impl Editor {
4141

4242
pub fn handle_message<T: Into<Message>>(&mut self, message: T) -> Vec<FrontendMessage> {
4343
self.dispatcher.handle_message(message);
44+
4445
let mut responses = Vec::new();
4546
std::mem::swap(&mut responses, &mut self.dispatcher.responses);
47+
4648
responses
4749
}
4850
}

frontend/src/components/panels/Document.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ import { defineComponent } from "vue";
227227
import { ResponseType, registerResponseHandler, Response, UpdateCanvas, UpdateScrollbars, SetActiveTool, SetCanvasZoom, SetCanvasRotation } from "@/utilities/response-handler";
228228
import { SeparatorDirection, SeparatorType } from "@/components/widgets/widgets";
229229
import { comingSoon } from "@/utilities/errors";
230+
import { panicProxy } from "@/utilities/panic";
230231
231232
import LayoutRow from "@/components/layout/LayoutRow.vue";
232233
import LayoutCol from "@/components/layout/LayoutCol.vue";
@@ -245,7 +246,7 @@ import OptionalInput from "@/components/widgets/inputs/OptionalInput.vue";
245246
import ToolOptions from "@/components/widgets/options/ToolOptions.vue";
246247
import { SectionsOfMenuListEntries } from "@/components/widgets/floating-menus/MenuList.vue";
247248
248-
const wasm = import("@/../wasm/pkg");
249+
const wasm = import("@/../wasm/pkg").then(panicProxy);
249250
250251
const documentModeEntries: SectionsOfMenuListEntries = [
251252
[

frontend/src/components/panels/LayerTree.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@
182182
import { defineComponent } from "vue";
183183
184184
import { ResponseType, registerResponseHandler, Response, BlendMode, ExpandFolder, CollapseFolder, UpdateLayer, LayerPanelEntry, LayerType } from "@/utilities/response-handler";
185+
import { panicProxy } from "@/utilities/panic";
185186
import { SeparatorType } from "@/components/widgets/widgets";
186187
187188
import LayoutRow from "@/components/layout/LayoutRow.vue";
@@ -195,7 +196,7 @@ import IconLabel from "@/components/widgets/labels/IconLabel.vue";
195196
import DropdownInput from "@/components/widgets/inputs/DropdownInput.vue";
196197
import { SectionsOfMenuListEntries } from "@/components/widgets/floating-menus/MenuList.vue";
197198
198-
const wasm = import("@/../wasm/pkg");
199+
const wasm = import("@/../wasm/pkg").then(panicProxy);
199200
200201
const blendModeEntries: SectionsOfMenuListEntries = [
201202
[{ label: "Normal", value: BlendMode.Normal }],

frontend/src/components/widgets/floating-menus/DialogModal.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@
5757
5858
.main-column {
5959
.heading {
60-
white-space: pre;
60+
white-space: pre-wrap;
61+
max-width: 400px;
6162
margin-bottom: 4px;
6263
}
6364
6465
.details {
65-
white-space: pre;
66+
white-space: pre-wrap;
67+
max-width: 400px;
6668
}
6769
6870
.buttons-row {

frontend/src/components/widgets/inputs/MenuBarInput.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,14 @@
5454
import { defineComponent } from "vue";
5555
5656
import { comingSoon } from "@/utilities/errors";
57+
import { panicProxy } from "@/utilities/panic";
5758
5859
import IconLabel from "@/components/widgets/labels/IconLabel.vue";
5960
import { ApplicationPlatform } from "@/components/window/MainWindow.vue";
6061
import MenuList, { MenuListEntry, MenuListEntries } from "@/components/widgets/floating-menus/MenuList.vue";
6162
import { MenuDirection } from "@/components/widgets/floating-menus/FloatingMenu.vue";
6263
63-
const wasm = import("@/../wasm/pkg");
64+
const wasm = import("@/../wasm/pkg").then(panicProxy);
6465
6566
const menuEntries: MenuListEntries = [
6667
{

frontend/src/components/widgets/inputs/SwatchPairInput.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,13 @@
6969
import { defineComponent } from "vue";
7070
7171
import { rgbToDecimalRgb, RGB } from "@/utilities/color";
72+
import { panicProxy } from "@/utilities/panic";
7273
import { ResponseType, registerResponseHandler, Response, UpdateWorkingColors } from "@/utilities/response-handler";
7374
7475
import ColorPicker from "@/components/widgets/floating-menus/ColorPicker.vue";
7576
import FloatingMenu, { MenuDirection, MenuType } from "@/components/widgets/floating-menus/FloatingMenu.vue";
7677
77-
const wasm = import("@/../wasm/pkg");
78+
const wasm = import("@/../wasm/pkg").then(panicProxy);
7879
7980
export default defineComponent({
8081
components: {

frontend/src/components/widgets/options/ToolOptions.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@
3232
import { defineComponent, PropType } from "vue";
3333
3434
import { comingSoon } from "@/utilities/errors";
35+
import { panicProxy } from "@/utilities/panic";
3536
import { WidgetRow, SeparatorType, IconButtonWidget } from "@/components/widgets/widgets";
3637
3738
import Separator from "@/components/widgets/separators/Separator.vue";
3839
import IconButton from "@/components/widgets/buttons/IconButton.vue";
3940
import PopoverButton from "@/components/widgets/buttons/PopoverButton.vue";
4041
import NumberInput from "@/components/widgets/inputs/NumberInput.vue";
4142
42-
const wasm = import("@/../wasm/pkg");
43+
const wasm = import("@/../wasm/pkg").then(panicProxy);
4344
4445
export default defineComponent({
4546
props: {

frontend/src/components/window/title-bar/WindowButtonsWeb.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="window-buttons-web" @click="handleClick" :title="fullscreen.windowFullscreen ? 'Exit Fullscreen (F11)' : 'Enter Fullscreen (F11)'">
3-
<TextLabel v-if="requestFullscreenHotkeys" :italic="true">Click to access all hotkeys</TextLabel>
3+
<TextLabel v-if="requestFullscreenHotkeys" :italic="true">Go fullscreen to access all hotkeys</TextLabel>
44
<IconLabel :icon="fullscreen.windowFullscreen ? 'FullscreenExit' : 'FullscreenEnter'" />
55
</div>
66
</template>

0 commit comments

Comments
 (0)