Index: lib/aardvark.js |
=================================================================== |
--- a/lib/aardvark.js |
+++ b/lib/aardvark.js |
@@ -248,16 +248,21 @@ let Aardvark = exports.Aardvark = |
}, |
onMouseMove: function(event) |
{ |
this.mouseX = event.screenX; |
this.mouseY = event.screenY; |
this.hideSelection(); |
+ if (!this.browser) |
+ { |
+ // hideSelection() called quit() |
+ return; |
+ } |
let x = event.clientX; |
let y = event.clientY; |
// We might have coordinates relative to a frame, recalculate relative to top window |
let node = event.target; |
while (node && node.ownerDocument && node.ownerDocument.defaultView && node.ownerDocument.defaultView.frameElement) |
{ |
@@ -388,21 +393,34 @@ let Aardvark = exports.Aardvark = |
{ |
this.prevPos = pos; |
this.paintNode.addEventListener("MozAfterPaint", this.onAfterPaint, false); |
} |
}, |
hideSelection: function() |
{ |
- if (this.boxElem.parentNode) |
- this.boxElem.parentNode.removeChild(this.boxElem); |
+ try |
+ { |
+ if (this.boxElem.parentNode) |
+ this.boxElem.parentNode.removeChild(this.boxElem); |
+ } |
+ catch (e) |
+ { |
+ // Are we using CPOW whose process is gone? Quit! |
+ // Clear some variables to prevent recursion (quit will call us again). |
+ this.boxElem = {}; |
+ this.paintNode = null; |
+ this.quit(); |
+ return; |
+ } |
if (this.paintNode) |
this.paintNode.removeEventListener("MozAfterPaint", this.onAfterPaint, false); |
+ |
this.paintNode = null; |
this.prevPos = null; |
}, |
getWindowSize: function(wnd) |
{ |
return [wnd.innerWidth, wnd.document.documentElement.clientHeight]; |
}, |