Skip to content

Commit 7e54d38

Browse files
author
Gary Keeble
committed
Patch for null userSettings error
1 parent 91a22c2 commit 7e54d38

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

js/main.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ function BlackboxLogViewer() {
499499
if (graph) {
500500
graph.destroy();
501501
}
502+
502503

503504
if((flightLog.getSysConfig().loopTime != null) &&
504505
(flightLog.getSysConfig().frameIntervalPNum != null) &&
@@ -697,14 +698,6 @@ function BlackboxLogViewer() {
697698
graphConfig = GraphConfig.getExampleGraphConfigs(flightLog, ["Motors", "Gyros"]);
698699
}
699700
});
700-
701-
prefs.get('userSettings', function(item) {
702-
if(item) {
703-
userSettings = item;
704-
} else {
705-
userSettings = null;
706-
}
707-
});
708701

709702
// Workspace save/restore to/from file.
710703
function saveWorkspaces(file) {
@@ -1078,7 +1071,19 @@ function BlackboxLogViewer() {
10781071

10791072
keysDialog = new KeysDialog($("#dlgKeysDialog")),
10801073

1081-
userSettingsDialog = new UserSettingsDialog($("#dlgUserSettings"), function(newSettings) {
1074+
userSettingsDialog = new UserSettingsDialog($("#dlgUserSettings"),
1075+
function(defaultSettings) { // onLoad
1076+
1077+
prefs.get('userSettings', function(item) {
1078+
if(item) {
1079+
userSettings = item;
1080+
} else {
1081+
userSettings = defaultSettings;
1082+
}
1083+
});
1084+
},
1085+
1086+
function(newSettings) { // onSave
10821087
userSettings = newSettings;
10831088

10841089
prefs.set('userSettings', newSettings);

js/user_settings_dialog.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
function UserSettingsDialog(dialog, onSave) {
3+
function UserSettingsDialog(dialog, onLoad, onSave) {
44

55
// Private Variables
66

@@ -36,7 +36,7 @@ function UserSettingsDialog(dialog, onSave) {
3636

3737
// Setup Defaults....
3838

39-
var currentSettings = {
39+
var defaultSettings = {
4040
mixerConfiguration : 3, // Default to Quad-X
4141
customMix : null, // Default to no mixer configuration
4242
stickMode : 2, // Default to Mode 2
@@ -48,7 +48,9 @@ function UserSettingsDialog(dialog, onSave) {
4848
drawAnalyser :true, // add an analyser option
4949
analyserSampleRate :2000/*Hz*/, // the loop time for the log
5050
eraseBackground : true // Set to false if you want the graph to draw on top of an existing canvas image
51-
}
51+
};
52+
53+
var currentSettings = {};
5254

5355
function saveCustomMix() {
5456

@@ -199,11 +201,16 @@ function UserSettingsDialog(dialog, onSave) {
199201
stickModeSelection(parseInt($(this).val()));
200202
});
201203

204+
// Initialise the userSettings
205+
206+
onLoad(defaultSettings);
207+
202208
// Public variables
209+
203210

204211
this.show = function(flightLog, settings) {
205212

206-
currentSettings = $.extend(currentSettings, settings || {});
213+
currentSettings = $.extend(defaultSettings, currentSettings, settings || {});
207214

208215
getAvailableMotors(flightLog); // Which motors are in the log file ?
209216

0 commit comments

Comments
 (0)