Skip to content

Commit

Permalink
Fix ImGui localStorage errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Deseteral committed Oct 8, 2023
1 parent 098ee8e commit b19ed99
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/imgui/imgui-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ export function Init(value: HTMLCanvasElement | WebGL2RenderingContext | WebGLRe

if (typeof (window) !== 'undefined') {
io.BackendPlatformName = 'imgui_impl_browser';
ImGui.LoadIniSettingsFromMemory(window.localStorage.getItem('imgui.ini') || '');
try {
const settings = window.localStorage.getItem('imgui.ini') || ''
ImGui.LoadIniSettingsFromMemory(settings);
} catch (err) { }
} else {
io.BackendPlatformName = 'imgui_impl_console';
}
Expand Down Expand Up @@ -331,7 +334,9 @@ export function NewFrame(time: number): void {
if (io.WantSaveIniSettings) {
io.WantSaveIniSettings = false;
if (typeof (window) !== 'undefined') {
window.localStorage.setItem('imgui.ini', ImGui.SaveIniSettingsToMemory());
try {
window.localStorage.setItem('imgui.ini', ImGui.SaveIniSettingsToMemory());
} catch (err) { }
}
}

Expand Down

0 comments on commit b19ed99

Please sign in to comment.