diff --git a/examples/libraries/toolBars.js b/examples/libraries/toolBars.js index 16c68a73fb..abe8de8cc3 100644 --- a/examples/libraries/toolBars.js +++ b/examples/libraries/toolBars.js @@ -362,8 +362,11 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit this.fractionKey = optionalPersistenceKey + '.fraction'; this.save = function () { var screenSize = Controller.getViewportDimensions(); - var fraction = {x: that.x / screenSize.x, y: that.y / screenSize.y}; - Settings.setValue(this.fractionKey, JSON.stringify(fraction)); + if (screenSize.x > 0 && screenSize.y > 0) { + // Guard against invalid screen size that can occur at shut-down. + var fraction = {x: that.x / screenSize.x, y: that.y / screenSize.y}; + Settings.setValue(this.fractionKey, JSON.stringify(fraction)); + } } } else { this.save = function () { }; // Called on move. Can be overriden or extended by clients.