Skip to content

Commit

Permalink
Fixed null-pointer exceptions
Browse files Browse the repository at this point in the history
Signed-off-by: paulober <44974737+paulober@users.noreply.github.com>
  • Loading branch information
paulober committed May 20, 2024
1 parent 16ff40f commit 64d10c6
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions web/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,22 +158,43 @@ function restoreState(state) {
// instead of setting ninja-radio-default-version if selection is undefined or 0,
// first check so the default can be controlled in the html
if (state.ninjaMode !== undefined) {
document.getElementById('ninja-radio-default-version').checked = state.ninjaMode == 0;
document.getElementById('ninja-radio-system-version').checked = state.ninjaMode == 1;
const ninjaDefaultVersionRadio = document.getElementById('ninja-radio-default-version');
if (ninjaDefaultVersionRadio) {
ninjaDefaultVersionRadio.checked = state.ninjaMode == 0;
}
const ninjaSystemVersionRadio = document.getElementById('ninja-radio-system-version');
// not available in the DOM is system ninja is not available
if (ninjaSystemVersionRadio) {
ninjaSystemVersionRadio.checked = state.ninjaMode == 1;
}
document.getElementById('ninja-radio-select-version').checked = state.ninjaMode == 2;
document.getElementById('ninja-radio-path-executable').checked = state.ninjaMode == 3;
}

if (state.cmakeMode !== undefined) {
document.getElementById('cmake-radio-default-version').checked = state.cmakeMode == 0;
document.getElementById('cmake-radio-system-version').checked = state.cmakeMode == 1;
const cmakeDefaultVersionRadio = document.getElementById('cmake-radio-default-version');
if (cmakeDefaultVersionRadio) {
cmakeDefaultVersionRadio.checked = state.cmakeMode == 0;
}
const cmakeSystemVersionRadio = document.getElementById('cmake-radio-system-version');
// not available in the DOM is system cmake is not available
if (cmakeSystemVersionRadio) {
cmakeSystemVersionRadio.checked = state.cmakeMode == 1;
}
document.getElementById('cmake-radio-select-version').checked = state.cmakeMode == 2;
document.getElementById('cmake-radio-path-executable').checked = state.cmakeMode == 3;
}

if (state.pythonMode !== undefined) {
document.getElementById('python-radio-default-version').checked = state.pythonMode == 0;
document.getElementById('python-radio-system-version').checked = state.pythonMode == 1;
if (state.pythonMode !== undefined && document.getElementById('python-radio-path-executable') !== undefined) {
const pythonDefaultVersionRadio = document.getElementById('python-radio-default-version');
if (pythonDefaultVersionRadio) {
pythonDefaultVersionRadio.checked = state.pythonMode == 0;
}
const pythonSystemVersionRadio = document.getElementById('python-radio-system-version');
// not available in the DOM is system python is not available
if (pythonSystemVersionRadio) {
pythonSystemVersionRadio.checked = state.pythonMode == 1;
}
document.getElementById('python-radio-path-executable').checked = state.pythonMode == 2;
}

Expand Down

0 comments on commit 64d10c6

Please sign in to comment.