Skip to content

Commit

Permalink
Fix webview disposed before setting html will crash panel without pro…
Browse files Browse the repository at this point in the history
…per disposables handling

Signed-off-by: paulober <[email protected]>
  • Loading branch information
paulober committed Sep 6, 2024
1 parent d915369 commit 6336f0b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/webview/newProjectPanel.mts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import {
loadExamples,
setupExample,
} from "../utils/examplesUtil.mjs";
import { unknownErrorToString } from "../utils/errorHelper.mjs";

export const NINJA_AUTO_INSTALL_DISABLED = false;
// process.platform === "linux" && process.arch === "arm64";
Expand Down Expand Up @@ -1175,7 +1176,18 @@ export class NewProjectPanel {
);

if (html !== "") {
this._panel.webview.html = html;
try {
this._panel.webview.html = html;
} catch (error) {
this._logger.error(
"Failed to set webview html. Webview might have been disposed. Error: ",
unknownErrorToString(error)
);
// properly dispose panel
this.dispose();

return;
}
await this._updateTheme();
} else {
void window.showErrorMessage(
Expand Down

0 comments on commit 6336f0b

Please sign in to comment.