diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index 6fc9ecb371..f769820f65 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -119,11 +119,10 @@ Zotero.Integration = new function() { } if(pipeInitialized) { - var me = this; // if initialization succeeded, add an observer so that we don't hang shutdown var observerService = Components.classes["@mozilla.org/observer-service;1"] .getService(Components.interfaces.nsIObserverService); - observerService.addObserver({ observe: me.destroy }, "quit-application", false); + observerService.addObserver({ observe: Zotero.Integration.destroy }, "quit-application", false); } } @@ -210,7 +209,13 @@ Zotero.Integration = new function() { .createInstance(Components.interfaces.nsIWorkerFactory) .newChromeWorker("chrome://zotero/content/xpcom/integration_worker.js"); worker.onmessage = function(event) { - Zotero.Integration.execCommand(event.data[0], event.data[1], event.data[2]); + if(event.data[0] == "Exception") { + throw event.data[1]; + } else if(event.data[0] == "Debug") { + Zotero.debug(event.data[1]); + } else { + Zotero.Integration.execCommand(event.data[0], event.data[1], event.data[2]); + } } worker.postMessage({"path":_fifoFile.path, "libc":libc}); diff --git a/chrome/content/zotero/xpcom/integration_worker.js b/chrome/content/zotero/xpcom/integration_worker.js index 856167cb03..81d8255eaa 100644 --- a/chrome/content/zotero/xpcom/integration_worker.js +++ b/chrome/content/zotero/xpcom/integration_worker.js @@ -52,11 +52,17 @@ onmessage = function(event) { close(fd); // extract message - var parts = buf.readString().match(/^([^ \n]*) ([^ \n]*)(?: ([^\n]*))?\n?$/); + string = buf.readString(); + var parts = string.match(/^([^ \n]*) ([^ \n]*)(?: ([^\n]*))?\n?$/); + if(!parts) { + postMessage(["Exception", "Integration Worker: Invalid input received: "+string]); + continue; + } var agent = parts[1].toString(); var cmd = parts[2].toString(); var document = parts[3] ? parts[3] : null; if(agent == "Zotero" && cmd == "shutdown") { + postMessage(["Debug", "Integration Worker: Shutting down"]); lib.close(); return; }